Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all
- format compact
- nntwarn off
- P=-1:0.1:-0.5;
- T=[-0.9602 -0.5770 0.0729 0.3771 0.6405 0.66];
- [R, Q] = size(P);[S1, Q] = size(T);
- S1 = 15;
- [S2, Q] = size(T);
- [W1,B1]=nwtan(S1,R);
- [W2, B2] = rands(S2, S1);
- disp_freq=100;
- max_epoch=50000;
- err_goal=1e-20;
- lr=0.03;
- A1=tansig(W1*P,B1);
- A2=purelin(W2*A1, B2);
- E=T-A2;
- SSE=sumsqr(E);
- error=[];
- for epoch=1:max_epoch
- if SSE<err_goal, epoch=epoch-1;
- break
- end;
- D2 = deltalin(A2, E);
- D1 = deltatan(A1, D2, W2);
- [dW2, dB2]=learnbp(A1, D2, lr);
- [dW1, dB1] =learnbp(P, D1, lr);
- W1=W1+dW1;
- B1=B1+dB1;
- W2=W2+dW2;
- B2=B2+dB2;
- A1=tansig(W1*P,B1);
- A2=purelin(W2*A1, B2);
- E=T-A2;
- SSE=sumsqr(E);
- error=[error SSE];
- if(rem(epoch,disp_freq)==0)
- epoch
- SSE
- plot(P,T,'r',P,A2,'g')
- pause(1e-120)
- end
- end;
Add Comment
Please, Sign In to add comment