2

我正在尝试使用经过训练的反向传播神经网络在新数据集上使用神经网络包来生成预测。我使用了“计算”功能,但最终得到的所有观察值都相同。我做错了什么?

# 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
4

1 回答 1

2

我能够使以下工作:

library(neuralnet)

# 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=10, learningrate=0.01)

print (backnet)


Var2<-c(1:10)^2

valnet = compute(backnet, Var2)

print (valnet$net.result)

回报:

     [,1]
[1,] 0.9341689395
[2,] 1.9992711472
[3,] 3.0012823496
[4,] 3.9968226732
[5,] 5.0038316976
[6,] 5.9992936957
[7,] 6.9991576925
[8,] 7.9996871591
[9,] 9.0000849977
[10,] 9.9891334545

根据神经网络参考手册,该包的默认训练算法是反向传播:

神经网络用于使用反向传播、弹性反向传播 (RPROP) 和 (Riedmiller, 1994) 或不使用权重回溯 (Riedmiller and Braun, 1993) 或 Anastasiadis 等人的修改后的全局收敛版本 (GRPROP) 来训练神经网络。(2005 年)。该功能允许通过自定义选择错误和激活功能进行灵活设置。此外,还实现了广义权重的计算(Intrator O. 和 Intrator N.,1993)。

于 2013-10-06T19:19:51.943 回答