Guest User

Untitled

a guest
May 27th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. clear all;
  2. clc;
  3. %Deklarasi Data
  4. x1 = [2 1 0 2 0];
  5. x2 = [3 1 3 1 0];
  6. d1 = [17 3 9 9 0];
  7. %Input Weight & Bias
  8. w11 = 0.1;
  9. w12 = -0.1;
  10. w2 = 0;
  11. w31 = 0;5;
  12. w32 = -0;5;
  13. w41 = 0.2;
  14. w42 = 0;
  15. w43 = -0.2;
  16. b1 = 0.1;
  17. b2 = 0.2;
  18. b3 = 0.3;
  19. b4 = 0.4;
  20. %Iteration, Eta dan A
  21. a = 0.8;
  22. eta = 0.01;
  23. iter = 5000;
  24. %Perhitungan
  25. for i=i:iter;
  26. %Perhitungan Neuron
  27. net1 = [w11 w12]*[x1;x2] + b1;
  28. y1 = 1./(1+exp(a*(-net1)));
  29. net2 = (x2*w2) + b2;
  30. y2 = 1./(1+exp(a*(-net2)));
  31. net3 = [w31 w32]*[x1;x2] + b3;
  32. y3 = 1./(1+exp(a*(-net3)));
  33. net4 = [w41 w42 w43]*[y1;y2;y3] + b4;
  34. y4 = a*net4;
  35. %Nilai Error
  36. delta1 = d1 - y4;
  37. %Feedback Neuron 4
  38. w41 = w41 + eta*a*delta1*y1';
  39. w42 = w42 + eta*a*delta1*y2';
  40. w43 = w43 + eta*a*delta1*y3';
  41. b4 = b4 + eta*delta1*ones(1,length(d1))';
  42. %Feedback Neuron 3
  43. w31 = w31 + eta*delta1*w43*a^2*(x1.*y3.*(1-y3))';
  44. w32 = w32 + eta*delta1*w43*a^2*(x2.*y2.*(1-y2))';
  45. b3 = b3 + eta*delta1*w43*a^2*(y3.*(1-y3))';
  46. %Feedback Neuron 2
  47. w2 = w2 + eta*delta1*w42*a^2*(x2.*y2.*(1-y2))';
  48. b2 = b2 + eta*delta1*w42*a^2*(y2.*(1-y2))';
  49. %Feedback Neuron 1
  50. w11 = w11 + eta*delta1*w41*a^2*(x1.*y1.*(1-y1))';
  51. w12 = w12 + eta*delta1*w41*a^2*(x2.*y1.*(1-y1))';
  52. b1 = b1 + eta*delta1*w41*a^2*(y1.*(1-y1))';
  53. %Cetak Iterasi
  54. fprintf('Iteration %i: Delta = %4.2e w11=%4.2e w12=%4.2e w2=%4.2e w31=%4.2e w32=%4.2e w41=%4.2e w42=%4.2e w43=%4.2e b1=%4.2e b2=%4.2e b3=%4.2e b4=%4.2e\r',i,sum(abs(delta1)),w11,w12,w2,w31,w32,w41,w42,w43,b1,b2,b3,b4);
  55. end
  56. d1;
  57. y4;
Add Comment
Please, Sign In to add comment