Advertisement
Sawy3R11

SI_lab4_siec_neuronowa

May 8th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.68 KB | None | 0 0
  1. clear all
  2. format compact
  3. nntwarn off
  4.  
  5. P=-1:0.1:-0.5;
  6. T=[-0.9602 -0.5770 0.0729 0.3771 0.6405 0.66];
  7. [R, Q] = size(P);
  8. [S1,Q]=size(T);
  9. [W1,B1]=nwtan(S1,R);
  10.  
  11. disp_freq=100;
  12. max_epoch=20000;
  13. err_goal=0.01;
  14. lr=0.1;
  15.  
  16. A1=tansig(W1*P,B1);
  17. E=T-A1;
  18. SSE=sumsqr(E);
  19. error=[];
  20.  
  21.  
  22. for epoch=1:max_epoch
  23.     if SSE<err_goal, epoch=epoch-1;
  24.         break
  25.     end;
  26.     D1=deltatan(A1,E);
  27.     [dW1, dB1]=learnbp(P, D1, lr);
  28.     W1=W1+dW1;
  29.     B1=B1+dB1;
  30.    
  31.     A1=tansig(W1*P,B1);
  32.     E=T-A1;
  33.     SSE=sumsqr(E);
  34.     error=[error SSE];
  35.    
  36.     if(rem(epoch,disp_freq)==0)
  37.         epoch
  38.         SSE
  39.         plot(P,T,'r',P,A1,'g')
  40.         pause(1e-120)
  41.     end
  42. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement