Advertisement
pabloducato

Untitled

Jun 13th, 2018
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.79 KB | None | 0 0
  1. clear all
  2. close all
  3. format compact
  4. nntwarn off
  5.  
  6.     Pn = -1:0.1:-0.5;
  7.     Tn = [-.9602 -.5770 -.0729 .3771 .6405 .6600];
  8.  
  9.     S1_vec      = [7]%Ilość neuronów w pierwszej warstwie
  10.     S2_vec      = [7];      %Ilość neuronów w drugiej warstwie
  11.     [S3,Q]      = size(Tn); %Ilość neuronów w warstwie wyjściowej
  12.     disp_freq   = 500;      %TP(1) - Epochs between updating display, default = 25.
  13.     max_epoch   = 10000;    %TP(2) - Maximum number of epochs to train, default = 1000.
  14.     err_goal    = 0.001;        %TP(3) - Sum-squared error goal, default = 0.02.
  15.     lr          = 0.001;    %TP(4) - Learning rate, 0.01.
  16.     lr_inc_vec  = [1.05];   %TP(5) - Learning rate increase, default = 1.05. %FOR
  17.     lr_dec_vec  = [0.7];    %TP(6) - Learning rate decrease, default = 0.7. %FOR
  18.     mc_vec      = [0.9];        %TP(7) - Momentum constant, default = 0.9. %FOR
  19.     er_vec      = [1.04];   %TP(8) - Maximum error ratio, default = 1.04. %FOR
  20.  
  21.     liczba_petli = length(S1_vec)*length(S2_vec)*length(lr_inc_vec)*length(lr_dec_vec)*length(er_vec)*length(mc_vec);
  22.     ind_petli = 0;
  23.     ind_petli2 = 0;
  24.  
  25.     qmax=0;
  26.     SSEmin=10000;
  27.  
  28.     for ind_S1=1:length(S1_vec),
  29.         for ind_S2=1:length(S2_vec),      
  30.             for ind_lr_inc=1:length(lr_inc_vec),
  31.                 for ind_lr_dec=1:length(lr_dec_vec),
  32.                         for ind_er=1:length(er_vec),
  33.                             [W1,B1,W2,B2,W3,B3] = initff(Pn,S1_vec(ind_S1),'tansig',S2_vec(ind_S2),'tansig',S3,'purelin');
  34.                             save wagi
  35.                             TP = [disp_freq max_epoch err_goal lr lr_inc_vec(ind_lr_inc) lr_dec_vec(ind_lr_dec) er_vec(ind_er)];              
  36.                             [W1,B1,W2,B2,W3,B3,TE,TR] = trainbpa(W1,B1,'tansig',W2,B2,'tansig',W3,B3,'purelin',Pn,Tn,TP);
  37.                             a = simuff(Pn,W1,B1,'tansig',W2,B2,'tansig',W3,B3,'purelin');
  38.                             q = (1-sum(abs(Tn-a)>=0.5)/length(Pn))*100;
  39.                             SSE = TR(1,TE+1);
  40.                         end
  41.                     end
  42.             end
  43.         end
  44.     end
  45. epoch
  46. SSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement