Advertisement
Guest User

Untitled

a guest
May 25th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.59 KB | None | 0 0
  1. A=[-1,-1,-1,-1,-1,-1;
  2.    -1,-1,1,1,-1,-1;
  3.    -1,1,-1,-1,1,-1;
  4.    -1,1,-1,-1,1,-1;
  5.    -1,1,1,1,1,-1;
  6.    -1,1,-1,-1,1,-1;
  7.    -1,1,-1,-1,1,-1;
  8.    -1,-1,-1,-1,-1,-1];
  9.  
  10. B=[-1,-1,-1,-1,-1,-1;
  11.    -1,1,1,1,-1,-1;
  12.    -1,1,-1,-1,1,-1;
  13.    -1,1,1,1,-1,-1;
  14.    -1,1,-1,-1,1,-1;
  15.    -1,1,-1,-1,1,-1;
  16.    -1,1,1,1,-1,-1;
  17.    -1,-1,-1,-1,-1,-1];
  18.  
  19. C=[-1,-1,-1,-1,-1,-1;
  20.    -1,-1,1,1,1,-1;
  21.    -1,1,-1,-1,-1,-1;
  22.    -1,1,-1,-1,-1,-1;
  23.    -1,1,-1,-1,-1,-1;
  24.    -1,1,-1,-1,-1,-1;
  25.    -1,-1,1,1,1,-1;
  26.    -1,-1,-1,-1,-1,-1];
  27.  
  28. D=[-1,-1,-1,-1,-1,-1;
  29.    -1,1,1,1,-1,-1;
  30.    -1,1,-1,-1,1,-1;
  31.    -1,1,-1,-1,1,-1;
  32.    -1,1,-1,-1,1,-1;
  33.    -1,1,-1,-1,1,-1;
  34.    -1,1,1,1,-1,-1;
  35.    -1,-1,-1,-1,-1,-1];
  36.  
  37. figure(1)
  38. subplot(2,2,1)
  39. hintonw(A)
  40. subplot(2,2,2)
  41. hintonw(B)
  42. subplot(2,2,3)
  43. hintonw(C)
  44. subplot(2,2,4)
  45. hintonw(D)
  46. A1 = reshape(A,48,1);
  47. B1 = reshape(B,48,1);
  48. C1 = reshape(C,48,1);
  49. D1 = reshape(D,48,1);
  50.  
  51. T=[A1,B1,C1,D1];
  52.  
  53. %whos('T')
  54.  
  55. net = newhop(T);
  56. %whos('net')
  57. disp('Rozmiar macierzy wag: ')
  58. disp(net.LW)
  59. disp('Zawartość macierzy wag: ')
  60. disp(net.LW{1})
  61. disp('Rozmiar wektora wsp. progowych: ')
  62. disp(net.b)
  63. disp('Zawartość wektora wsp. progowych: ')
  64. disp(net.b{1})
  65.  
  66. %Druga część zadania
  67. %stopniowo zwiększać ilość zakłuceń
  68. AZ=[-1,-1,-1,-1,-1,-1;
  69.    -1,1,1,1,-1,-1;
  70.    -1,-1,1,-1,1,-1;
  71.    -1,1,1,1,1,1;
  72.    -1,1,1,1,1,-1;
  73.    -1,1,-1,-1,1,-1;
  74.    -1,1,1,-1,1,-1;
  75.    -1,-1,-1,1,-1,-1];
  76.  
  77. BZ=[-1,-1,-1,-1,-1,-1;
  78.    -1,1,1,1,-1,-1;
  79.    -1,1,-1,-1,1,-1;
  80.    -1,1,1,-1,-1,-1;
  81.    1,1,-1,-1,1,-1;
  82.    -1,1,-1,-1,1,-1;
  83.    -1,1,1,1,-1,-1;
  84.    -1,-1,-1,-1,-1,-1];
  85.  
  86. CZ=[-1,-1,-1,-1,-1,1;
  87.    1,-1,1,-1,1,-1;
  88.    -1,1,1,-1,1,-1;
  89.    -1,1,-1,-1,-1,-1;
  90.    -1,1,-1,-1,-1,-1;
  91.    -1,1,-1,-1,-1,-1;
  92.    -1,-1,1,1,1,-1;
  93.    -1,-1,-1,-1,-1,-1];
  94.  
  95. DZ=[-1,-1,-1,-1,-1,-1;
  96.    -1,1,1,1,-1,-1;
  97.    -1,1,-1,1,1,-1;
  98.    -1,1,-1,-1,1,-1;
  99.    -1,1,-1,-1,1,-1;
  100.    -1,1,-1,-1,1,-1;
  101.    -1,1,1,1,-1,-1;
  102.    -1,-1,-1,-1,-1,-1];
  103.  
  104. figure(2)
  105. subplot(2,2,1)
  106. hintonw(AZ)
  107. subplot(2,2,2)
  108. hintonw(BZ)
  109. subplot(2,2,3)
  110. hintonw(CZ)
  111. subplot(2,2,4)
  112. hintonw(DZ)
  113. AZ1 = reshape(AZ,48,1);
  114. BZ1 = reshape(BZ,48,1);
  115. CZ1 = reshape(CZ,48,1);
  116. DZ1 = reshape(DZ,48,1);
  117.  
  118. TZ=[AZ1,BZ1,CZ1,DZ1];
  119.  
  120. LS=4; %stany poczatkowe
  121. KS=200; %kroki zmieniac do ststow
  122.  
  123. Y=sim(net,{LS KS},{},{TZ});
  124.  
  125. disp(Y)
  126. disp(Y{1})
  127. disp(Y{2})
  128.  
  129. figure(2)
  130.  
  131. for i=1:LS
  132.     subplot(2,2,i)
  133.     hintonw(reshape(TZ(:,i),8,6))
  134. end
  135.  
  136. pause(1)
  137.  
  138. for j=1:KS
  139.     for k=1:LS
  140.         subplot(2,2,k)
  141.         Z=reshape(Y{j}(:,k),8,6)
  142.         hintonw(Z)
  143.         %E(k)=(-1/2)*mpower(Y,T)*W*Y(k)-mpower(b,T)*Y(k)
  144.         %disp(E)
  145.     end
  146.     pause(1)
  147. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement