如何从训练好的NARX神经网络中进行预测?
24次浏览(过去30天)
显示旧的注释
我从一篇研究论文中获得了以下代码,该论文实现了一个使用外源输入训练网络的NARX神经网络:
% Anp -输入时间序列。
% Adtds -反馈时间序列。
X = tonndata(Anp,true,false);
T = tonndata(Adtds,true,false);
选择'trainlm'训练函数
trainFcn =“trainlm”;% Levenberg-Marquardt反向传播。
%模型创建
inputdelayed = 1:2;
feedbackdelayed = 1:2;
hiddenLayerSize = 10;
net = narxnet(inputdelayed, feedbackdelayed,hiddenLayerSize,“开放”, trainFcn);
%训练及模拟数据准备
[x,xi,ai,t] = preparets(net, x, {}, t);
为训练、验证和测试划分数据。
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 0/100;
net.divideParam.testRatio = 30/100;
网divideFcn =“divideblock”;
网络培训
[net,tr] = train(net,x,t,xi,ai);
%网络测试
Y = net(x,xi,ai);
E = gsubtract(t,y);
性能=执行(净,t,y)
%网络视图
视图(净)
%的情节
图中,plotperform (tr)
图中,plottrainstate (tr)
图中,ploterrhist (e)
图,plotregression (t, y)
图,plotresponse (t, y)
图中,ploterrcorr (e)
图中,plotinerrcorr (x, e)
%闭环网络
Netc = cloloop (net);
net.name = [net.name .“-闭环”];
视图(netc)
[xc,xic,aic,tc] = preparets(netc,X,{},T);
Yc = netc(xc,xic,aic);
closedLoopPerformance = execute (net,tc,yc)
步进预测网络
net = removedelay(net);
net.name = [net.name .“提前预测一步”];
视图(网)
[xs,xis,ais,ts] = preparets(nets,X,{},T);
Ys = nets(xs,xis,ais);
steppaheadperformance =执行(nets,ts,ys)
我能理解它是在训练网络。但我无法理解如何预测网络从未见过的新输入数据的输出。我尝试使用net(input_Series),但它给了我输入不充分的错误。有人能帮帮我吗?