Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all
- nntwarn off
- format compact
- P = -1:.1:-.5;
- T = [-.9602 -.5770 -.0729 .3771 .6405 .6600];
- [R,Q] = size(P);
- [S1,Q] = size(T);
- [S2,Q] = size(T);
- [S3,Q] = size(T);
- [W1,B1] = nwtan(S1,R);
- [W2,B2] = nwtan(S2,S1);
- [W3,B3] = rands(S3,S2);
- disp_freq = 100;
- max_epoch = 10000;
- err_goal = 0.01;
- lr = 0.001;
- error = [];
- A1 = tansig(W1*P,B1);
- A2 = tansig(W2*A1,B2);
- A3 = purelin(W3*A2,B3);
- E = T - A3;
- SSE = sumsqr(E);
- save wagi
- for (epoch=1:max_epoch)
- if (SSE < err_goal)
- epoch = epoch - 1;
- break
- end
- D3 = deltalin(A3,E);
- D2 = deltatan(A2,D3,W3);
- D1 = deltatan(A1,D2,W2);
- [dW1,dB1] = learnbp(P,D1,lr);
- [dW2,dB2] = learnbp(A1,D2,lr);
- [dW3,dB3] = learnbp(A2,D3,lr);
- W1 = W1 + dW1;
- B1 = B1 + dB1;
- W2 = W2 + dW2;
- B2 = B2 + dB2;
- W3 = W3 + dW3;
- B3 = B3 + dB3;
- A1 = tansig(W1*P,B1);
- A2 = tansig(W2*A1,B2);
- A3 = purelin(W3*A2,B3);
- E = T-A3;
- SSE = sumsqr(E);
- error = [error SSE];
- if (rem(epoch,disp_freq)==0)
- epoch
- SSE
- plot(P,T,'r',P,A3,'g')
- pause(1e-5)
- end
- end
- epoch
- SSE
Add Comment
Please, Sign In to add comment