NARX神经网络预测? [英] NARX Neural network prediction?

查看:936
本文介绍了NARX神经网络预测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Matlab提供的NARX神经网络解决方案来解决时间序列问题.我试图了解如何预测实际值,但是我得到的结果几乎是完美的!错误是如此之小,以至于我不确定我是否真的在预测.我只想确保我做的一切正确!

I am trying to solve a time series problem using the NARX Neural Network solution that Matlab provides. I am trying to understand how to predict actual values, but the results I get are almost perfect! The errors are so small that I am not sure if I am actually predicting. I just want to make sure I am doing everything right!

基本上,我使用GUI解决方案对网络进行了一些样本训练.然后,我使用以下脚本使用新样本测试神经网络:

Basically I train the network with some samples using the GUI solution. Then I use the following script to test the neural network with new samples:

      X = num2cell(open2(1:end))'; % input
      T = num2cell(close2(1:end))'; % this is the output I should get

      net = removedelay(net);
      [Xs,Xi,Ai,Ts] = preparets(net,X,{},T);

      Y = net(Xs,Xi,Ai);

      plotresponse(Ts,Y)
      view(net)

      Y = cell2mat(Y);
      T = cell2mat(T);

      sizey = length(Y);
      sizet = length(T);

      T = T(1:sizey);

      figure
      plot(1:sizey,T,1:sizey,Y)

我得到的图形几乎与原始目标时间序列函数相同.误差确实很小,唯一的区别是图形(Y)向左移动了2个样本.但是,我真的在预测吗?

The graph I am getting is almost identical to the original target time series function. The errors are really small and the only difference is that the graph (Y) is shifted 2 samples to the left. But, am I really predicting?

这是图形的一部分:

提前谢谢!

更新:实际的预测图向右移动,而不向左移动. preparets功能提供的目标(蓝色)早于!因此,它并不表明它实际上是在预测.

Update: The actual prediction graph is shifted to the right and not to the left. The targets provided by the preparets function (blue) occurs before! So it doesn't show it's actually predicting.

推荐答案

右移

您的显示时移为1(不是2!)个时间步.这不是理想的,但是当延迟选择不当导致这种延迟模式时,可能会发生这种情况. (有关详细说明,请参见此问题实际上,格雷格·希思(Greg Heath)在ANN上发布了 lot 资料,尽管有时可能需要立即理解,尤其是对于初学者而言,它有时还是很短,但还是值得一读.)因此,请避免这种情况您必须研究数据的相关性模式.

Right Shift

Your graph shows a timeshift of 1 (not 2!) timestep(s). This is not ideal, but can happen when the delays are badly chosen which leads to this kind of delay pattern. (For further explanation have a look at this question on MATLAB CENTRAL. In fact, Greg Heath posted a lot of material on ANNs, very worth the read even though it's sometimes a bit short to be understood immediately, especially for beginners.) So, to avoid this you have to look into the correlation patterns of your data.

现在,我假设您想通过消除网络延迟来纠正此问题.不幸的是,这不是 removedelay()的含义:

Now, I'm assuming that you wanted to correct for this behaviour by removing the delay of the network instead. Unfortunately, this is not what removedelay() is meant for:

此示例使用timedelaynet ,但也可以用于NAR和NARX网络,我发现该说明非常有帮助.结合已删除elay的文档

This example uses a timedelaynet, but can be adopted for NAR and NARX networks as well, and I found the description very helpful. In combination with a quote from removedelay's documentation

结果是一个网络,其行为相同,只是输出在n个时间步之后生成.

The result is a network which behaves identically, except that outputs are produced n timesteps later.

很明显,您没有更改网络,而是只更改了y值的时间依赖性,因此您的网络将尝试预测向前的时间.您可以在T和Y向量的最后看到这种行为,其中Y将具有附加值,而T用NaN填充此空间(因为显然您不能从蓝中生成更多目标).

it becomes clear that you're not changing the network, instead you only change the time dependence of your y-values, so your network will try to predict one time step ahead. You can see this behaviour at the very end of your T and Y vectors where Y will have an additional value while T fills this space with NaN (because you obviously cannot generate more targets out of the blue).

removedelay()应该与闭环设计结合使用,以便您可以及早获得预测值,并将其用作下一步的直接输入.在这种情况下,将输出延迟增加一个以上也是有意义的,这就是为什么您可以传递附加参数n:

removedelay() is supposed to be used in combination with a closed loop design, so that you can obtain predicted values early to use them as direct input for the next step. In this case, it also makes sense to increase the output delay by more than just one which is why you can pass an additional argument n:

net = removedelay(net,n);

要证明未使用额外的时间步长,您可以使用受过训练的网络模拟所需的数据集,然后使用removedelay()模拟相同的数据集.除了Y曲线的最后一个值(见图1)之外,它们将是相同的.

To prove that the additional time step is not used you can simulate the desired data set with your trained net and then simulate the same set with removedelay(). They are going to be identical except for the last value of the Y curve (see Figure 1).

图. 1:两个图均基于使用MATLAB的热交换器示例的前3500个数据点训练的同一网络.显示的是训练过程中未使用的集合中最后500个值的模拟结果.结果相同,除了使用removedelay()左边的附加值.

Fig. 1: Both plots are based on the same net trained with the first 3500 data points of MATLAB's heat exchanger example. Shown are the simulation results for the last 500 values in the set that have not been used in the training process. The results are identical except for an additional value for the one on the left using removedelay().

您的错误必须很小.因此,对于类似的新数据的预测会很好,因为您的网络不会过拟合.

Your errors have to be very small if you're using a representative training set. Therefore, the prediction for similar, new data will be good because your net is not overfitted.

所以,您预测吗?不,您在模拟.模拟网络的行为是基于先前未知数据集的输入,而不是目标(必须通过传递它们才能进行性能评估).因此,在两种情况下,无论有没有removedelay()都将新数据传递到您的网络是模拟的,因为这是基于提供的输入.消除延迟对这些结果没有影响.
另一方面,预测不需要输入数据,因为它实际上只是在延续网络迄今为止所学的模式,而无需考虑新的输入.

So, are you predicting? No, you are simulating. Simulating your network's behaviour is based on inputs of your previously unknown data set, not the targets (they only have to be passed to allow for performance evaluation). Therefore, passing new data to your net with or without removedelay() is simulation in both cases because it is based on provided inputs. Removing the delay doesn't make a difference for these results.
Prediction, on the other hand, requires no input data because it really just continues the pattern the network has learned so far without taking new input into account.

如果您只想拥有一个未知的数据集,并将有效的输入值传递给网络进行仿真,则可以使用测试集的一部分传递>或divideint选项.

If all you want is to have an unknown data set with valid input values passed to your net for simulation, you could just as well pass it as part of the testing set by using the divideblock or divideint options.

如果您想使用removedelay()进行的早期预测,或者由于输入存在漏洞或由于其他原因而不可靠而通常需要进行预测,则应考虑使用闭环模拟未知集合.如果它的性能太糟糕了,您还可以从一开始就训练一个闭环网络.

If you want to make use of early prediction by removedelay() or need prediction in general because your inputs have holes or are unreliable for other reasons, you should consider simulating your unknown set with a closed loop. Should its performance be all too awful you can also train a closed loop network from the very beginning.

这篇关于NARX神经网络预测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆