Advertisement
LukacikPavel

cv02

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