new 2星 星星 2010 07 15 22:24BP神神我我matlab实实和matlab工工工和和实使神经最经稍经使经的神神我我学学,终也所我终和和matlab实实BP我我网网个网。也这这这感感然然sistor2004的的的《自自自的BP网法(工工:matlab))和然然wangleisxcc的的的《和C++,Matlab,Fortran实实的BP网法 )前前前前我实BP网法如为每注算的算算,然前后我实matlab然BP稍稍的和和如为我终为函。因作因因因的的的网因如平注因,实我对稍对对对使如稍设对对,所均我我sistor2004因的的的稍平修修然平注为的的函因,误方稍对对对。%严严严严BP我我网网网网网设网的稍和matlab的的,实BP我我也就为网我设网%yyy,网即o(k)网网网网使,当我我也输用用用使(<0.0001)学学学平也, 也网然学学学出出出%v(i,j)=v(i,j)+deltv(i,j)+a*dv(i,j); 动网动clear allclcinputNums=3; %输输设隐设outputNums=3; %输也设隐设hideNums=10; %设设隐设稍maxcount=20000; %最也迭迭迭稍samplenum=3; %稍和网稍一,无无无precision=0.001; %预设即梯yyy=1.3; %yyy然前前我我平增是也用用用alpha=0.01; %学学学设设作a=0.5; %BP网我网法的稍和设设作,实的也训训的使调作严比使修修 字字9error=zeros(1,maxcount+1); %error稍也我我我;增的然预网目如目目经errorp=zeros(1,samplenum); %同的v=rand(inputNums,hideNums); %3*10;v我我我作稍和3*10的网随的稍的的; v表输输设如设设的网作deltv=zeros(inputNums,hideNums); %3*10;如目目经预网目dv=zeros(inputNums,hideNums); %3*10;w=rand(hideNums,outputNums); *3;同Vdeltw=zeros(hideNums,outputNums);*3dw=zeros(hideNums,outputNums); *3samplelist=[0.1323,0.323,-0.132;0.321,0.2434,0.456;-0.6546,-0.3242,0.3255]; %3*3;上设输输作3*3(实作3和网网)expectlist=[0.5435,0.422,-0.642;0.1,0.562,0.5675;-0.6464,-0.756,0.11]; %3*3;星也输也作3*3(实作3和网网),如输有的有有学学count=1;while (count<=maxcount) %也也另另1迭迭20000迭c=1;while (c<=samplenum)for k=1:outputNumsd(k)=expectlist(c,k); %获然星也输也的网网,d(1:3)表显稍和星也网网如 的作endfor i=1:inputNumsx(i)=samplelist(c,i); %获然输输的网网(稍数),x(1:3)表稍和训训网网字字4end%Forward();for j=1:hideNumsnet=0.0;for i=1:inputNumsnet=net+x(i)*v(i,j);%输输设如设设的平网和∑X(i)V(i)end-1-new 2星 星星 2010 07 15 22:24y(j)=1/(1+exp(-net)); %输也设输输f(x)=1/(1+exp(-x))简单单sigmiod稍稍endfor k=1:outputNumsnet=0.0;for j=1:hideNumsnet=net+y(j)*w(j,k);endif count>=2&&error(count)-error(count+1)<=0.0001o(k)=1/(1+exp(-net)/yyy); %用用用平也学学学else o(k)=1/(1+exp(-net)); %同的endend%BpError(c)反反/修修;errortmp=0.0;for k=1:outputNumserrortmp=errortmp+(d(k)-o(k))^2; %第稍也训训然的显显网网enderrorp(c)=0.5*errortmp; %显显E=∑(d(k)-o(k))^2 * 1/2%endockward();for k=1:outputNumsyitao(k)=(d(k)-o(k))*o(k)*(1-o(k)); %输输设显显输输 字字5endfor j=1:hideNumstem=0.0;for k=1:outputNumstem=tem+yitao(k)*w(j,k); %作为为设设输输,而网网的∑endyitay(j)=tem*y(j)*(1-y(j)); %设设输输end%使调调设网作for j=1:hideNumsfor k=1:outputNumsdeltw(j,k)=alpha*yitao(k)*y(j); %网作w的使调网deltw(已已学学学)w(j,k)=w(j,k)+deltw(j,k)+a*dw(j,k);%网作使调,也这的dw=dletw(t-1),实实然实BP网法的稍和dw(j,k)=deltw(j,k); %修也改改--增平动网动增的然增增训训增梯endendfor i=1:inputNumsfor j=1:hideNumsdeltv(i,j)=alpha*yitay(j)*x(i); %同的deltwv(i,j)=v(i,j)+deltv(i,j)+a*dv(i,j);dv(i,j)=deltv(i,j);endendc=c+1;end%第也和while也也;表显稍迭BP训训也也double tmp;tmp=0.0; 字字8for i=1:samplenumtmp=tmp+errorp(i)*errorp(i);%显显为和endtmp=tmp/c;error(count)=sqrt(tmp);%显显为均误误,网即梯if (error(count)
好文档 - 专业文书写作范文服务资料分享网站