<%
library("neuralnet")
library(rjson)
# 1. creating the initial data, plotting
data <- data.frame (
input = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
output = c(1, 4, 9, 16, 25, 36, 49, 64, 81)
)
#plot(data$output ~ data$input, main="Distribution of the pension relative to the salary", xlab="Salary", ylab="Pension")
#Train the neural network
#Going to have 10 hidden layers
#Threshold is a numeric value specifying the threshold for the partial
#derivatives of the error function as stopping criteria.
net.sqr <- neuralnet(output~input,data, hidden=10, threshold=0.01)
print(net.sqr)
#Plot the neural network
#plot(net.sqr)
#Test the neural network on some training data
testdata <- as.data.frame(3) #Generate some squared numbers
net.results <- compute(net.sqr, testdata) #Run them through the neural network
#Lets see what properties net.sqr has
ls(net.results)
#Lets see the results
print(net.results$net.result)
#Lets display a better version of the results
cleanoutput <- cbind(testdata,testdata*testdata,
as.data.frame(net.results$net.result))
colnames(cleanoutput) <- c("Input","Expected Output","Neural Net Output")
print(cleanoutput)
%>
<%
cat(toJSON(net.results$net.result))
%>
Возможно я делал что-то еще, что помнил, написал.
Связаться с программистом сайта.
Новые книги авторов СИ, вышедшие из печати:
О.Болдырева "Крадуш. Чужие души"
М.Николаев "Вторжение на Землю"
Как попасть в этoт список