声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 4719|回复: 10

[共享资源] [推荐]一个经典的BP网络原程序

[复制链接]
发表于 2006-5-10 12:18 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
对于初学者是挺有用的
边看边学
  1. %
  2. clf; figure(1); setfsize(500,300); echo on; clc; pause % 键入任意键继续
  3. clc; P = [-3.0 +2.0]; T = [+0.4 +0.8]; pause
  4. clc; wv = -4:0.4:7.6; bv = -4:0.4:7.6; es = errsurf(P,T,wv,bv,'logsig');
  5. plotes(wv,bv,es,[60 30]); pause
  6. clc; net=newff(minmax(P),[1],{'logsig'},'traingd','learngd','sse');
  7. net.iw{1,1}; net.b{1}; pause; echo off; k = pickic(1);
  8. if k == 2, net.iw{1,1} = -2.1617; net.b{1} = -1.7862;
  9. elseif k == 3, subplot(1,2,2); h=text(2,2,sprintf('Click on me'))
  10. [net.iw{1,1},net.b{1}] = ginput(1); delete(h)
  11. end
  12. echo on; clc

  13. net.trainParam.show = 5; % 学习过程显示频率
  14. net.trainparam.goal = 0.01; % 误差指标
  15. net.trainParam.lr = 2;% 学习率
  16. me=100; A=sim(net,P); sse=sumsqr(T-A);
  17. h=plotep(net.iw{1,1},net.b{1},sse)
  18. for i=1:me
  19. if sse<net.trainParam.goal,i=i-1;break,end
  20. net.trainParam.epochs=1;
  21. figure(2); setfsize(50,50); [net,tr] = train(net,P,T);
  22. trp(i)=tr.perf(1,2); A=sim(net,P); sse=sumsqr(T-A);
  23. if rem(i,net.trainParam.show)==0
  24. figure(1); h=plotep(net.iw{1,1},net.b{1},sse,h);
  25. end
  26. end
  27. tr.p=trp(1:i);
  28. message=sprintf('Train:%%g/%g epochs,sse=%%g.\n',me);
  29. fprintf(message,i,sse)
  30. figure(1); plotep(net.iw{1,1},net.b{1},sse,h); pause
  31. subplot(1,2,2); plot(1:i,tr.p); hold on
  32. plot(1:i,net.trainParam.goal,'r--'); hold off
  33. title('Error Signals'); xlabel('Epochs'); ylabel('Error'); pause
  34. p = -1.2; a = sim(net,p); echo off
复制代码

[ 本帖最后由 ChaChing 于 2009-12-28 14:49 编辑 ]

评分

1

查看全部评分

回复
分享到:

使用道具 举报

发表于 2006-5-18 17:33 | 显示全部楼层
??? Undefined command/function 'setfsize'.<BR>能把这个m文件给出来吗?
发表于 2006-5-18 21:39 | 显示全部楼层

有的 函数已经作废了

setfsize是什么函数<BR>还有pickic提示是作废的函数
发表于 2006-6-29 15:34 | 显示全部楼层
却是,没见过这个函数<BR>
发表于 2006-8-27 10:02 | 显示全部楼层

函数

好多函数都没有见过阿,行不行啊,不过 仍然谢谢
发表于 2006-8-29 10:20 | 显示全部楼层

确实不行

Undefined function or variable 'setfsize'.

.m
On line 4  ==> setfsize(500,300);
发表于 2006-11-3 19:48 | 显示全部楼层
我也试了试,有好多函数每见过,程序通不过
发表于 2006-11-7 10:57 | 显示全部楼层
  1. function h=setfsize(wx,wy)
  2. % h=setfsize (wx,wy)
  3. %
  4. % Set figure position.       
  5. %
  6. % h = setfsize(X,Y)
  7. %   X - Horizontal length.
  8. %   Y - Vertical height.
  9. % h is the figure handle to the figure just handled
  10. % Sets current figure lower left position to X by Y pixels (measured from
  11. % lower left corner of screen. On image, max pixels are about
  12. % 1280, 1024, you can use  get (0,'ScreenSize') to get the screen size
  13. %
  14. %  adapted from function setfsize.m
  15. %
  16. %                                Ziad Saad Sept 27 97


  17. z = get(gcf,'position');
  18. set(gcf,'position',[z(1) z(2) wx wy]);
  19. h = gcf;
  20. return;
复制代码

评分

1

查看全部评分

发表于 2006-11-7 10:59 | 显示全部楼层
把setfsize这个函数加上就可正常运行了

不过里边存在若干作废函数
 楼主| 发表于 2006-11-7 21:20 | 显示全部楼层
呵呵  suffer真强!
发表于 2006-11-8 16:33 | 显示全部楼层
原帖由 lxq 于 2006-11-7 21:20 发表
呵呵  suffer真强!


这个在网络上就能够找到
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-25 01:16 , Processed in 0.065362 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表