我正在尝试使用经过训练的反向传播神经网络在新数据集上使用神经网络包来生成预测。我使用了“计算”功能,但最终得到的所有观察值都相同。我做错了什么?
# the data
Var1 <- runif(50, 0, 100)
sqrt.data <- data.frame(Var1, Sqrt=sqrt(Var1))
# training the model
backnet = neuralnet(Sqrt~Var1, sqrt.data, hidden=2, err.fct="sse", linear.output=FALSE, algorithm="backprop", learningrate=0.01)
print (backnet)
Call: neuralnet(formula = Sqrt ~ Var1, data = sqrt.data, hidden = 2, learningrate = 0.01, algorithm = "backprop", err.fct = "sse", linear.output = FALSE)
1 repetition was calculated.
Error Reached Threshold Steps
1 883.0038185 0.009998448226 5001
valnet = compute(backnet, (1:10)^2)
summary (valnet$net.result)
V1
Min. :0.9998572
1st Qu.:0.9999620
Median :0.9999626
Mean :0.9999505
3rd Qu.:0.9999626
Max. :0.9999626
print (valnet$net.result)
[,1]
[1,] 0.9998572272
[2,] 0.9999477241
[3,] 0.9999617930
[4,] 0.9999625684
[5,] 0.9999625831
[6,] 0.9999625831
[7,] 0.9999625831
[8,] 0.9999625831
[9,] 0.9999625831
[10,] 0.9999625831