《附加动量法BP网络MATLAB程序》由会员分享,可在线阅读,更多相关《附加动量法BP网络MATLAB程序(2页珍藏版)》请在金锄头文库上搜索。
1、clear all ;P=-6.0 -6.1 -4.1 -4.0 5.0 -5.1 6.0 6.1;T=0 0 0.97 0.99 0.01 0.03 1.0 1.0;R,Q=size(P);S,Q=size(T);disp( The bias B is fixed at 300 and will not learn)Z1=menu( Initialize Weight with:, .W0=-0.9;B0=3; , .Pick Values with Mouse/Arrow Keys, .Random Initial ConditionDefault; );disp( )B0=3;if Z1
2、=1W0=-0.9;elseif Z1=3W0=rand(S,R);enderror1=;net=newcf(minmax(P),1, logsig ); net.b1=B0;j=-1:0.1:1;for i=1:21;net.iw1,1=j(i); y=sim(net,P); err=sumsqr(y-T);error1=error1 err;endplot(j,error1);xlabel( Input Vector );ylabel( One Dimention Error Curve ) hold on;Z2=menu( Use momentum constant of :, .0.0
3、 , .0.95 Default );if Z1=2 W0,dummy=ginput(1);end disp( ) if Z2=1 momentum=0;else momentum=0.95;end ls=;error=;w=; max_epoch=500;err_goal=0.01;lp.lr=0.05;lp.mc=momentum;err_ratio=1.04;W=W0;B=B0;A=logsig(W0*P+B0*ones(1,8);E=T-A;SSE=sumsqr(E);for epoch=1:max_epoch if SSESSE*err_ratio mc=0;elseif TSSESSE mc=momentum;end W=TW;A=TA; E=TE; SSE=TSSE; error=error TSSE; w=w W;endplot(w,error, rp xlabel( Input Vector hold off ;););ylabel(Weight );figure;plot(error);xlabel( Input Vector);ylabel(Training Error);