store performance coefficient of different iterations in a vector
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Rik
2022-3-14
编辑:Rik
2022-3-14
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!