store performance coefficient of different iterations in a vector
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mahmoud Zemzami
le 14 Mar 2022
Commenté : Mahmoud Zemzami
le 15 Mar 2022
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 commentaires
Réponse acceptée
Rik
le 14 Mar 2022
Modifié(e) : Rik
le 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!