2

我正在尝试使用 nnet 方法拟合神经网络。但由于某种原因,我得到了拟合值 =1 。有什么建议吗?

traininginput <-  as.data.frame(runif(50, min=0, max=100))
trainingoutput <- sqrt(traininginput)

#Column bind the data into one variable
trainingdata <- cbind(traininginput,trainingoutput)
colnames(trainingdata) <- c("Input","Output")


nnet1=nnet(trainingdata$Input,trainingdata$Output,size=10,decay=.2,MaxNWts=100)

nnet1=nnet(trainingdata$Input,trainingdata$Output,size=10,decay=.2,MaxNWts=100)
# weights:  31
initial  value 2398.911170 
iter  10 value 1881.721970
iter  20 value 1879.273609
iter  30 value 1879.248746
final  value 1879.248003 
converged

nnet1$fitted.values
          [,1]
 [1,] 0.9995635611
 [2,] 0.9995572993
 [3,] 0.9994755520
 [4,] 0.9995623911
 [5,] 0.9946006508
 [6,] 0.9995635779
 [7,] 0.9995108061
 [8,] 0.9995635025
 [9,] 0.9995634973
[10,] 0.9993213029
[11,] 0.9994652808
[12,] 0.9979116411
[13,] 0.9993242430
[14,] 0.9995635764
[15,] 0.9995632595
[16,] 0.9995583546
[17,] 0.9992778848
[18,] 0.9995635364
[19,] 0.9939526885
[20,] 0.9995635788
[21,] 0.9993010783
[22,] 0.9995597586
[23,] 0.9995635748
[24,] 0.9995635799
[25,] 0.9995634813
[26,] 0.9992898229
[27,] 0.9959834977
[28,] 0.9991941868
[29,] 0.9995632224
[30,] 0.9995486025
[31,] 0.9995608608
[32,] 0.9995635755
[33,] 0.9995635740
[34,] 0.9995491922
[35,] 0.9995635661
[36,] 0.9995629924
[37,] 0.9995634948
[38,] 0.9994889240
[39,] 0.9995633558
[40,] 0.9995559725
[41,] 0.9995563696
[42,] 0.9995564636
[43,] 0.9995602699
[44,] 0.9995635768
[45,] 0.9995612253
[46,] 0.9895069469
[47,] 0.9995271104
[48,] 0.9995635564
[49,] 0.9995635797
[50,] 0.9995609961
4

1 回答 1

1

linout = TRUE参数添加到nnet函数中:

nnet1=nnet(trainingdata$Input,trainingdata$Output,size=10,decay=.2,MaxNWts=100, linout = TRUE)

那应该可以解决您的问题!默认情况下,拟合值是逻辑输出单位 - 请参阅?nnet

于 2013-08-12T18:06:49.523 回答