0% found this document useful (0 votes)
28 views2 pages

'Algoritma Pembelajaran Back Propagation XOR' ' - ' 'Lany Rahmawati - 140110100050' 'Masukkan Jumlah Maksimum Epoh: '

This document contains code for an algorithm to implement backpropagation for an XOR problem. It defines variables for the number of epochs, learning rate, weights, biases, input and target data. It then runs a loop for the specified number of epochs or until the mean squared error is below a threshold, calculating the outputs, errors and updating the weights and biases to minimize the error through backpropagation.

Uploaded by

lanyrahmawati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

'Algoritma Pembelajaran Back Propagation XOR' ' - ' 'Lany Rahmawati - 140110100050' 'Masukkan Jumlah Maksimum Epoh: '

This document contains code for an algorithm to implement backpropagation for an XOR problem. It defines variables for the number of epochs, learning rate, weights, biases, input and target data. It then runs a loop for the specified number of epochs or until the mean squared error is below a threshold, calculating the outputs, errors and updating the weights and biases to minimize the error through backpropagation.

Uploaded by

lanyrahmawati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

clc;

disp('Algoritma Pembelajaran Back Propagation XOR');


disp('-------------------------------------------');
disp('Lany Rahmawati - 140110100050')
epoh = input('masukkan jumlah maksimum Epoh : ');
a=0.35;
b=10^-10;
v=[0.9562 0.7762 0.1623 0.2886;0.1962 0.6133 0.0311 0.9711];
b1=[0.7496 0.3796 0.7256 0.1628];
w=[0.2280; 0.9585; 0.6799 ;0.0550];
b2=0.9505;
x=[0 0; 0 1;1 0; 1 1];
t=[0;1;1;0];
mse=1;
i=0;
while(i<=epoh)&&(mse>=b)
e=0;
%iterasi ke-i
for j=1:4
%data ke-j
for k=1:4
z_in(1,k)=0;
end
for k=1:4
b1(1,k)
x(j,2)*v(2,j);
x(j,1)*v(1,j);
z_in(1,k)=b1(1,k)+(x(j,1)*v(1,k)+x(j,2)*v(2,k));
end
for k=1:4
z(1,k)=1/(1+exp(-z_in(1,k)) );
end
test=0;
for k=1:4
test=test+(w(k,1)*z(1,k));
end
y=b2+test;
error=t(j,1)-y;
e=e+error*error;
delta=error;
db2=a*delta;
for k=1:4
dw(k,1)=a*delta*z(1,k);
end
for k=1:4
delta_in=delta*w(k,1);
delta1(1,k)=delta_in*-1*(1+exp(-z_in(1,k)))^-2*-exp(-z_in(1,k));
db1(1,k)=a*delta1(1,k);
dv(1,k)=db1(1,k)*x(j,1);
dv(2,k)=db1(1,k)*x(j,2);
end
for k=1:2
for l=1:4
v(k,l)=v(k,l)+dv(k,l);
end
end

for k=1:4
b1(1,k)=b1(1,k)+db1(1,k);
end

for k=1:4
w(k,1)=w(k,1)+dw(k,1);
end

b2=b2+db2;
end
mse=e/4;
i=i+1;
end
v
b1
w
b2
mse=e/4
i

You might also like