问题
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