Advertisement
Guest User

halo

a guest
Oct 3rd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.76 KB | None | 0 0
  1. disp(w); % ekvivalentny zapis je : w = [-1 -2 -10] (bez bodkociarky)
  2.  
  3.  
  4. X = [
  5.      2 6 -1;
  6.      -1 -4 -1;
  7.      2 2 -1;
  8.      1 -3 -1;
  9.      -3 -1 -1;
  10.      -1 1 -1;
  11.      6 1 -1;
  12.      ];
  13. D = [ 1 -1 1 -1 1 1 -1];
  14. E = 0;
  15. k = 1;
  16.  
  17. function y = sign(hodnota)
  18.   if (hodnota >= 0)
  19.     y = 1;
  20.   else
  21.     y = -1;
  22.   endif
  23.  endfunction
  24.  
  25.  function w = uciacePravidloPerc(X, D, pocetEpoch = 1)
  26.    w = [-1 -2 10];
  27.    ro = 0.5;
  28.    for index = 1:pocetEpoch
  29.      for k = 1:rows(X)
  30.        x = X(k,:)
  31.        vystupPerceptronuY = sign(dot(w,x))
  32.        ocakavanaHodnotaD = D(k)
  33.        chyba = ocakavanaHodnotaD - vystupPerceptronuY
  34.        w= w + (ro*chyba*x)
  35.        endfor
  36.     endfor
  37.  endfunction
  38.  w = uciacePravidloPerc(X, D);
  39.  disp('Aktualizovane vahy: ');
  40.  disp(w);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement