Matlab -Neural Network Simulation (for Loop)

旧巷老猫 提交于 2019-12-25 04:58:16

问题


I am quiet new to matlab NN toolbox and have created the following NN network:

val.P=Exp;

net =newff(minmax(p),[20,3],{'tansig','purelin'},'trainlm');

net.trainParam.epochs = 5000;    %Max Ephocs
net.trainParam.goal = 1e-5;     %Training Goal in Mean Sqared Error
net.trainParam.min_grad = 0.05e-3;
net.trainParam.show = 50;       %# of ephocs in display
net.trainParam.max_fail =20;
net = init(net);

[net,tr]=train(net,p,t,[],[],val);
o1 = sim(net,Exp)

How can I run the above for say 20 times and store the data in one variable (o1)? Any help is very much appreciated !


回答1:


for iteration=1:20
  % Your NN code
  [net, tr]=train(net,p,t,[],[],val);
  o1(:,iteration) = sim(net,Exp);
end

After that, o1 will be an array with all the results in it.

Note: Since I don't know the dimensions of your data, you might need to modify o1(iteration) to o1(:,iteration) or o1(:,:,iteration) etc. Whatever you need.



来源:https://stackoverflow.com/questions/10534219/matlab-neural-network-simulation-for-loop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!