Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-10, 16:49   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 从命令行使用nntool [MATLAB]

我有以下代码:

in = [5 columns of data-points]; out = [1 column of data-points]; net = newfit(in,out,5); net = train(net,in,out); 现在我想
  • 访问所生成的错误变量 (以便我可以计算平均错误等)
  • 在一个循环中运行它,所以我想在循环之间重新初始化权重
  • 访问存储运行时间的变量
如何从命令行完成这三件事?

[我知道如何使用nntool GUI完成这些操作]


回答:
例:

% some random data in = rand(100,5)'; out = rand(100,1)'; % create a feed-forward back-propagation neural network % (1 hidden layer with 5 neurons) net = newfit(in,out,5); net.trainParam.showWindow = 0; % dont show GUI % repeat 10 times rmse = []; t = []; for i=1:10 net = init(net); % initialize network weights tic net = train(net,in,out); % train predicted = sim(net, in); % test t(i) = toc; r = (out - predicted); % residuals rmse(i) = sqrt(mean(r.^2)); % root mean square error end % plot errors and elapsed times bar([t; rmse]', 'grouped'), xlabel('Runs') legend({'Elapsed Time' 'RMSE'}, 'orientation','horizontal')

注意:在R2010b中,不建议使用newfit函数,而改用fitnet ,请改用以下代码创建网络:

% old %net = newfit(in,out,5); % new net = fitnet(5); % create ANN net = configure(net, in, out); % set input/output sizes according to data

更多&回答...
poster 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 23:44


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.