我正在使用R语言中的neuralnet
包编写神经网络,用于预测时间序列x + sin(x^2)
中的元素。以下是生成训练数据的方式,假设窗口大小为4个元素,最后一个元素是需要被预测的:
nntr0 <- ((1:25) + sin((1:25)^2))
nntr1 <- ((2:26) + sin((2:26)^2))
nntr2 <- ((3:27) + sin((3:27)^2))
nntr3 <- ((4:28) + sin((4:28)^2))
nntr4 <- ((5:29) + sin((5:29)^2))
然后,我将它们转化为数据框:
nntr <- data.frame(nntr0, nntr1, nntr2, nntr3, nntr4)
接着,我开始训练神经网络:
net.sinp <- neuralnet(nntr4 ~ nntr0 + nntr1 + nntr2 + nntr3, data=nntr, hidden=10, threshold=0.04, act.fct="tanh", linear.output=TRUE, stepmax=100000)
一段时间后,给我发送了消息。
Warning message:
algorithm did not converge in 1 of 1 repetition(s) within the stepmax
Call: neuralnet(formula = nntr4 ~ nntr0 + nntr1 + nntr2 + nntr3, data = nntr, hidden = 10, threshold = 0.04, stepmax = 100000, act.fct = "tanh", linear.output = TRUE)
有谁能帮我弄清楚为什么它无法收敛?非常感谢。