lxq 发表于 2006-5-10 12:18

[推荐]一个经典的BP网络原程序

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

net.trainParam.show = 5; % 学习过程显示频率
net.trainparam.goal = 0.01; % 误差指标
net.trainParam.lr = 2;% 学习率
me=100; A=sim(net,P); sse=sumsqr(T-A);
h=plotep(net.iw{1,1},net.b{1},sse)
for i=1:me
if sse<net.trainParam.goal,i=i-1;break,end
net.trainParam.epochs=1;
figure(2); setfsize(50,50); = train(net,P,T);
trp(i)=tr.perf(1,2); A=sim(net,P); sse=sumsqr(T-A);
if rem(i,net.trainParam.show)==0
figure(1); h=plotep(net.iw{1,1},net.b{1},sse,h);
end
end
tr.p=trp(1:i);
message=sprintf('Train:%%g/%g epochs,sse=%%g.\n',me);
fprintf(message,i,sse)
figure(1); plotep(net.iw{1,1},net.b{1},sse,h); pause
subplot(1,2,2); plot(1:i,tr.p); hold on
plot(1:i,net.trainParam.goal,'r--'); hold off
title('Error Signals'); xlabel('Epochs'); ylabel('Error'); pause
p = -1.2; a = sim(net,p); echo off

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

rolo 发表于 2006-5-18 17:33

??? Undefined command/function 'setfsize'.<BR>能把这个m文件给出来吗?

yu1983619 发表于 2006-5-18 21:39

有的 函数已经作废了

setfsize是什么函数<BR>还有pickic提示是作废的函数

hustbill 发表于 2006-6-29 15:34

却是,没见过这个函数<BR>

wxr1000 发表于 2006-8-27 10:02

函数

好多函数都没有见过阿,行不行啊,不过 仍然谢谢

dreambreez 发表于 2006-8-29 10:20

确实不行

Undefined function or variable 'setfsize'.

.m
On line 4==> setfsize(500,300);

wateropt 发表于 2006-11-3 19:48

我也试了试,有好多函数每见过,程序通不过

suffer 发表于 2006-11-7 10:57

function h=setfsize(wx,wy)
% h=setfsize (wx,wy)
%
% Set figure position.       
%
% h = setfsize(X,Y)
%   X - Horizontal length.
%   Y - Vertical height.
% h is the figure handle to the figure just handled
% Sets current figure lower left position to X by Y pixels (measured from
% lower left corner of screen. On image, max pixels are about
% 1280, 1024, you can useget (0,'ScreenSize') to get the screen size
%
%adapted from function setfsize.m
%
%                                Ziad Saad Sept 27 97


z = get(gcf,'position');
set(gcf,'position',);
h = gcf;
return;

suffer 发表于 2006-11-7 10:59

把setfsize这个函数加上就可正常运行了

不过里边存在若干作废函数

lxq 发表于 2006-11-7 21:20

呵呵suffer真强!

suffer 发表于 2006-11-8 16:33

原帖由 lxq 于 2006-11-7 21:20 发表
呵呵suffer真强!

这个在网络上就能够找到
页: [1]
查看完整版本: [推荐]一个经典的BP网络原程序