store performance coefficient of different iterations in a vector
2 views (last 30 days)
Show older comments
Hi everyone,
I developped a code for function approximation using neuralnetworks. the perfoamnce of each iteration is estimated using a performation coefficient (nse).
I want to store every nse coefficint of each iteration in a vector.
nse1=0.1;
% ANN Model--------------------------------
while nse1 < 0.44;
net=feedforwardnet([5 20 10]);
net.divideParam.trainRatio=0.7;
net.divideParam.testRatio=0.15;
net.divideParam.valRatio=0.15;
net.trainParam.lr=0.001;
net.trainParam.min_grad=1e-20;
net.trainParam.goal=1e-3;
net.trainParam.epochs=1000;
net.trainParam.show=20;
net.trainParam.max_fail=1000;
net.trainFcn = 'trainlm';
net.trainParam.mu=0.01;
% init_net = init(net);
net=train(net,ANN_Inputs,ANN_Target);
net_output1=net(ANN_Inputs);
Obs=ANN_Target';
Sim=net_output1';
% R2 = calculateR2(Obs,Sim)
nse1 = NSE(Obs,Sim)
end
0 Comments
Accepted Answer
Rik
on 14 Mar 2022
Edited: Rik
on 14 Mar 2022
Following the standard strategy:
nse1_vector=NaN(1,1000);
nse1_vector(1)=0.1;
nse1_index=1;
% ANN Model--------------------------------
while nse1_vector(nse1_index) < 0.44;
net=feedforwardnet([5 20 10]);
net.divideParam.trainRatio=0.7;
net.divideParam.testRatio=0.15;
net.divideParam.valRatio=0.15;
net.trainParam.lr=0.001;
net.trainParam.min_grad=1e-20;
net.trainParam.goal=1e-3;
net.trainParam.epochs=1000;
net.trainParam.show=20;
net.trainParam.max_fail=1000;
net.trainFcn = 'trainlm';
net.trainParam.mu=0.01;
% init_net = init(net);
net=train(net,ANN_Inputs,ANN_Target);
net_output1=net(ANN_Inputs);
Obs=ANN_Target';
Sim=net_output1';
% R2 = calculateR2(Obs,Sim)
nse1_index=nse1_index+1;
nse1_vector(nse1_index) = NSE(Obs,Sim);
fprintf('nse (it %d) = %.1f\n',nse1_index,nse1_vector(nse1_index))
end
nse1_vector((nse1_index+1):end)=[];
You can probably move a lot of that code outside of the loop, but I don't know enough of your application to suggest what exactly. Code that does not depend on the previous iteration should not be in the loop itself.
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!