Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all;
- clc;
- %Deklarasi Data
- x1 = [2 1 0 2 0];
- x2 = [3 1 3 1 0];
- d1 = [17 3 9 9 0];
- %Input Weight & Bias
- w11 = 0.1;
- w12 = -0.1;
- w2 = 0;
- w31 = 0;5;
- w32 = -0;5;
- w41 = 0.2;
- w42 = 0;
- w43 = -0.2;
- b1 = 0.1;
- b2 = 0.2;
- b3 = 0.3;
- b4 = 0.4;
- %Iteration, Eta dan A
- a = 0.8;
- eta = 0.01;
- iter = 5000;
- %Perhitungan
- for i=i:iter;
- %Perhitungan Neuron
- net1 = [w11 w12]*[x1;x2] + b1;
- y1 = 1./(1+exp(a*(-net1)));
- net2 = (x2*w2) + b2;
- y2 = 1./(1+exp(a*(-net2)));
- net3 = [w31 w32]*[x1;x2] + b3;
- y3 = 1./(1+exp(a*(-net3)));
- net4 = [w41 w42 w43]*[y1;y2;y3] + b4;
- y4 = a*net4;
- %Nilai Error
- delta1 = d1 - y4;
- %Feedback Neuron 4
- w41 = w41 + eta*a*delta1*y1';
- w42 = w42 + eta*a*delta1*y2';
- w43 = w43 + eta*a*delta1*y3';
- b4 = b4 + eta*delta1*ones(1,length(d1))';
- %Feedback Neuron 3
- w31 = w31 + eta*delta1*w43*a^2*(x1.*y3.*(1-y3))';
- w32 = w32 + eta*delta1*w43*a^2*(x2.*y2.*(1-y2))';
- b3 = b3 + eta*delta1*w43*a^2*(y3.*(1-y3))';
- %Feedback Neuron 2
- w2 = w2 + eta*delta1*w42*a^2*(x2.*y2.*(1-y2))';
- b2 = b2 + eta*delta1*w42*a^2*(y2.*(1-y2))';
- %Feedback Neuron 1
- w11 = w11 + eta*delta1*w41*a^2*(x1.*y1.*(1-y1))';
- w12 = w12 + eta*delta1*w41*a^2*(x2.*y1.*(1-y1))';
- b1 = b1 + eta*delta1*w41*a^2*(y1.*(1-y1))';
- %Cetak Iterasi
- 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);
- end
- d1;
- y4;
Add Comment
Please, Sign In to add comment