简体   繁体   English

神经网络预测变成一条直线

[英]Neural network Prediction becomes a straight line

I implemented a two-layer neural network (according to the Kolmogorov-Arnold theorem, this is enough to represent any nonlinear function of n variables) to predict time series.我实现了一个两层神经网络(根据 Kolmogorov-Arnold 定理,这足以表示 n 个变量的任何非线性函数)来预测时间序列。 However, by the end of the neural network, the volatility of the received forecast drops to almost zero and it turns into a straight line (I attach the forecast screen and the source code of the neural network).然而,到神经网络结束时,接收到的预测波动率下降到几乎为零,并变成一条直线(我附上预测屏幕和神经网络的源代码)。 I increased the number of neurons in the hidden layer, the number of epochs, the size of the training sample, the learning rate, changed the range of normalization of the training sample data, changed the range of initial weights.我增加了隐藏层的神经元数量、epoch 数、训练样本的大小、学习率,改变了训练样本数据的归一化范围,改变了初始权重的范围。 Nothing helps.没有什么帮助。 The size of the training sample is 336 examples, the training method is the reverse propagation of the error, the normalization method is minimax.训练样本大小为336个样本,训练方法为误差反向传播,归一化方法为minimax。 Moreover, when using the hyperbolic tangent as an activation function, the situation improves somewhat, but the graph also looks strange.此外,当使用双曲正切作为激活函数时,情况有所改善,但图形看起来也很奇怪。 A "direct forecast" is output from ReLU. ReLU 输出“直接预测”。 Does anyone have any ideas on this problem?有人对这个问题有任何想法吗?

import random
import sys
import numpy
import math

eta=0.0001 #learning rate
n=200 #number of training epoch. There were also 500, 1000, 5000
inp=30 #input layer size
m=60 #hidden layer size
y=0 #output signal
t=0 #target signal
e=0 #error
d_y=0 #local gradient for the last neuron
err=0 #calculated network error for output neuron
err_av=0 #average network error
path='dataTrain.txt' #training sample
path2='dataLaunch.txt' #launching a forecast
day = 365 #number of days of forecasting
...

The rest is on the site: https://ideone.com/vV2QW6其余的在网站上: https ://ideone.com/vV2QW6

Screenshot (activation function - sigmoid): https://ibb.co/GHrTGLr截图(激活函数-sigmoid): https ://ibb.co/GHrTGLr

Screenshot (activation function - hyperbolic tangent): https://ibb.co/WHFX3Sc截图(激活函数-双曲正切): https ://ibb.co/WHFX3Sc

Thanks for attention.感谢关注。

This question is difficult to answer because you are trying to solve a time series problem using a tool that is not designed for that purpose.这个问题很难回答,因为您正在尝试使用不是为此目的设计的工具来解决时间序列问题。 An RNN or LSTM would be more appropriate. RNN 或 LSTM 会更合适。

From what I understand reading the code you wrote, it seems you have fixed the input size (to 30 days) to predict the 31st day.根据我对您编写的代码的理解,您似乎已将输入大小(至 30 天)固定为预测第 31 天。 Then you slide the 30 day window to include that prediction (and exclude the 1st day) so that you can predict the 32nd day.然后滑动 30 天窗口以包含该预测(并排除第 1 天),以便您可以预测第 32 天。 If my understanding is correct, the phenomenon you encountered can be explained (I hope) simply:如果我的理解是正确的,你遇到的现象可以简单解释(我希望):

The prediction for day 31 and day 32 aren't expected to be that different because they are made from very similar inputs.预计第 31 天和第 32 天的预测不会有那么大的不同,因为它们是由非常相似的输入做出的。 Same for 32 and 33 etc. Eventually all the inputs become more similar (because these include the predictions which we've established are similar) and the outputs become more similar until you get something that looks constant. 32 和 33 等相同。最终所有输入变得更加相似(因为这些包括我们已经建立的预测是相似的)并且输出变得更加相似,直到你得到看起来恒定的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM