Closed Loop performance of trained NAR not good enough. Why?
2 次查看(过去 30 天)
显示 更早的评论
Hello, I'm using NAR to predict future values of my timeseries, but when I plot response of closed loop network I saw output shifts in time, I could not figure out why. Can anybody help me? Here are my codes, basically most of it generated from ntstool, and some are my modifications.
T = normalizedsolarpower;
N = length(T)
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Nonlinear Autoregressive Network
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narnet(feedbackDelays,hiddenLayerSize,'open',trainFcn);
% Prepare the Data for Training and Simulation
[x,xi,ai,t] = preparets(net,{},{},T);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x,t,xi,ai);
rng(0)
% Test the Network
y = net(x,xi,ai);
e = gsubtract(t,y);
performance = perform(net,t,y)
% View the Network
view(net)
% Closed Loop Network
netc = closeloop(net);
netc.name = [net.name ' - Closed Loop'];
view(netc)
[xc,xic,aic,tc] = preparets(netc,{},{},T);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(net,tc,yc)
plotresponse(tc,yc)
ypredic = netc(cell(0,96),xic,aic); % 96 step-ahead predictionwithout any input
figure
plot(cell2mat(ypredic))
legend('predicted values')
As you can see from plot the error is very high and it seems shift in period, and the closedloopperformance equals to 0.0615, which is high I guess. Any help will be appreciated. Thanks,
6 个评论
dpb
2018-8-29
I don't have NN TB so can't run your code; all I can do is look at the plots you've shown.
What's the real abscissa units for the normalized power? Looks like must be two days from general shape, length()/24/60/60 -> 0.84 so something around 1 sec sampling time?
Just out of curiosity, what's the reason for storing it as a cell array? It is just a double array but
>> whos normalizedsolarpower sp
Name Size Bytes Class Attributes
normalizedsolarpower 1x72867 8744040 cell
sp 1x72867 582936 double
>>
where
sp=cell2mat(normalizedsolarpower);
show it takes almost 9 MB to store the same data as is contained in just 600K as a double plus there's the added overhead of dereferencing a cell array to get the content plus the nuisance of having to use the "curlies" instead of just plan parentheses.
While it's not your problem, looks like could improve efficiency quite a bit by just converting to the double array.
回答(1 个)
Shashank Bhatia
2018-9-11
For standarized data (mean = 0 & Var = 1), Steps are as follows:
1. Calculate number of hidden layers and number of feedback delays. --> Via autocorrelation method
2. Selection of training function --> depending upon data complexity, length, and time available
3. Divide data between training, validation and Testing --> use divideblock
4. Training the open loop
5. Defining the closed loop network --> choosing appropriate function for closed loop
6. training the closed loop
7. after confirming accuracy (check mse and perform) of the models, use closed loop trained network for prediction.
1 个评论
Lucas Ferreira-Correia
2019-7-22
Hi when you said
"5. Defining the closed loop network --> choosing appropriate function for closed loop"
do you mean specify a different training solver or what do you mean?
In addition to that does
"6. training the closed loop"
mean that the closed loop should be trained again the exact same way as the open loop, so with the same data?
I realise this is an old thread but your help would be greatly appreaciated!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!