Lag in output from NarNetwork (narnet)
1 view (last 30 days)
Show older comments
% Solve an Autoregression Time-Series Problem with a NAR Neural Network % Script generated by Neural Time Series app % This script assumes this variable is defined: % % solarTargets - feedback time series.
T = solarTargets;
trainFcn = 'trainlm'; % Levenberg-Marquardt feedbackDelays = 1:6; hiddenLayerSize = 10; net = narnet(feedbackDelays,hiddenLayerSize,'open',trainFcn); net.input.processFcns = {'removeconstantrows','mapminmax'}; [x,xi,ai,t] = preparets(net,{},{},T); net.divideFcn = 'dividerand'; % Divide data randomly net.divideMode = 'time'; % Divide up every value net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100;
net.performFcn = 'mse'; % Mean squared error net.plotFcns = {'plotperform','plottrainstate','plotresponse', ... 'ploterrcorr', 'plotinerrcorr'};
% Train the Network [net,tr] = train(net,x,t,xi,ai);
% Test the Network y = net(x,xi,ai); e = gsubtract(t,y); performance = perform(net,t,y)
% Recalculate Training, Validation and Test Performance trainTargets = gmultiply(t,tr.trainMask); valTargets = gmultiply(t,tr.valMask); testTargets = gmultiply(t,tr.testMask); trainPerformance = perform(net,trainTargets,y) valPerformance = perform(net,valTargets,y) testPerformance = perform(net,testTargets,y)
% View the Network view(net)
% Closed Loop Network netc = closeloop(net); [xc,xic,aic,tc] = preparets(netc,{},{},T); yc = netc(xc,xic,aic); perfc = perform(net,tc,yc)
% Multi-step Prediction [x1,xio,aio,t] = preparets(net,{},{},T); [y1,xfo,afo] = net(x1,xio,aio); [netc,xic,aic] = closeloop(net,xfo,afo); [y2,xfc,afc] = netc(cell(0,5),xic,aic);
% Step-Ahead Prediction Network nets = removedelay(net); [xs,xis,ais,ts] = preparets(nets,{},{},T); ys = nets(xs,xis,ais); stepAheadPerformance = perform(net,ts,ys)

As shown in figure I am observing a lag in targets and output. But same was not observed when code ran for laserTargets series. For sake of understanding a lag only 20 values are plotted.
Help me to understand how to use "narnet".

0 Comments
Accepted Answer
Greg Heath
on 7 Sep 2014
The net was trained with 6 delays. Why don't you expect it to show in the plots?
Hope this helps.
Thank you for formally accepting my answer
Greg
More Answers (0)
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!