Matlab-神经网络仿真(用于循环) [英] Matlab -Neural Network Simulation (for Loop)

查看:89
本文介绍了Matlab-神经网络仿真(用于循环)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Matlab NN工具箱的新手,并创建了以下NN网络:

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)

如何运行上述命令20次并将数据存储在一个变量(o1)中? 非常感谢任何帮助!

解决方案

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

之后,o1将是一个数组,其中包含所有结果.

注意:由于我不知道数据的维度,因此您可能需要将o1(iteration)修改为o1(:,iteration)或o1(:,:: iteration)等.无论您需要什么.

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 !

解决方案

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.

这篇关于Matlab-神经网络仿真(用于循环)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆