我正在尝试进行简单的神经网络建模,但 NNet 结果给了我很差的结果。我希望 nnet 模型学习的只是“输出 = 0.5 x 输入”模型,但预测结果显示所有“1”。怎么了?
library(neuralnet)
traininginput <- as.data.frame(runif(50,min=1,max=100))
trainingoutput <- traininginput/2
trainingdata<-cbind(traininginput,trainingoutput)
colnames(trainingdata)<-c("Input","Output")
net.sqrt2 <- nnet(trainingdata$Output~trainingdata$Input,size=0,skip=T, linout=T)
Testdata<-as.data.frame(1:50)
net.result2<-predict(net.sqrt2, Testdata)
cleanoutput2 <- cbind(Testdata,Testdata/2,as.data.frame(net.result2))
colnames(cleanoutput2)<-c("Input2","Expected Output2","Neural Net Output2")
print(cleanoutput2)