用matlab实现BP算法出错?帮忙看下是什么问题
<P>网络输入是p,理想输出为t,设网络为两层,一个输入,隐层为5个神经元,输出层1个神经元。没有用神经网络工具箱。运行程序后,发现误差E在减小到一定程度后,又开始线性增加,不知道为什么会是这样?请各位大侠帮忙看下!!<BR><BR>t=[-0.96,-0.577,-0.0729,0.377,0.641,0.66,0.461,0.1336,-0.201,-0.434,-0.5,-0.393,-0.1647,0.0988,0.3072,0.396,0.3449,0.1816,-0.0312,-0.2183,-0.3201];<BR>p=-1:0.1:1;<BR><BR>=size(p); %Q为输入向量个数,和输出向量个数<BR>=size(t);<BR>S1=5; %S1为隐层神经元数目<BR>w1=rands(S1,R);%输入为一个<BR>w2=rands(S2,S1); %输出神经元为1个<BR>%plot(p,t,'*');<BR>%hold on;</P><P>max_epoch=18000;err_goal=0.01;lr=0.01;<BR>E=err_goal+1;N=0;<BR>while (E>err_goal)|(N<max_epoch)<BR> E=0;<BR> for i=1:Q<BR> for j=1:S1<BR> O1i(j)=tansig(p(i)*w1(j));<BR> V(j)=O1i(j)*w2(j);%实际输出值<BR> end<BR> O2(i)=purelin(sum(V));<BR> e(i)=(t(i)-O2(i))*(t(i)-O2(i))/2; %误差<BR> <BR> for m=1:S1<BR> Qq(m)=O2(i)*(1-O2(i))*(t(i)-O2(i));<BR> Qw2(m)=lr*Qq(m)*O1i(m);<BR> w2(m)=w2(m)+Qw2(m);%输出层权值调整<BR> Qq1(m)=O1i(m)*(1-O1i(m))*(w2(m)*Qq(m));<BR> Qw1(m)=lr*Qq1(m)*p(i);<BR> w1(m)=w1(m)+Qw1(m);%输入层权值调整<BR> end<BR> end<BR> <BR> E=sum(e)<BR> N=N+1<BR>end</P>
回复:(caixiaoyan)用matlab实现BP算法出错?帮忙看...
先用工具箱里的函数算一下这个模型,看结果怎么样
页:
[1]