Design of Perceptron AND network and program of Perceptron Training Algorithm
Design of Perceptron AND network and program of Perceptron Training Algorithm
Soft Computing
PROGRAM :
% Perceptron for AND Function clear;
clc;
x=[1 1 -1 -1;1 -1 1 -1];
t=[1 -1 -1 -1];
w=[0 0];
b=0;
alpha=input('Enter Learning
rate=');
theta=input('Enter
Threshold Value=');
con=1;
epoch=0;
while con
con=0;
for i=1:4
yin=b+x(1,i)*w(1)+x(2,i)*w(2);
if yin>theta y=1;
end
if yin<=theta &
yin>=-theta y=0;
end
if yin<-theta y=-1;
end
if y-t(i) con=1; for j=1:2
w(j)=w(j)+alpha*t(i)*x(j,i);
end
b=b+alpha*t(i);
end
end 0.
epoch=epoch+1;
end
disp('Perceptron for AND Function');
disp('Final Weight
Matrix');
disp(w);
disp('Final Bias');
disp(b);
disp('Perceptron for AND Function');
disp('Final Weight Matrix');
disp(w);
disp('Final Bias');
disp(b);
OUTPUT :
Enter Learning rate=1
Enter Threshold Value=0.5
Perceptron for AND Function
Final Weight Matrix
1 1
OUTPUT:
ANDNet_errors
= 0 0
0 0
>>
ANDNet_outputs
ANDNet_outputs
= 0 0
0 1
>>
ANDNet.iw{1,1}
ans
= 2 1
>>
ANDNet.b{1}
ans
= -3
Comments
Post a Comment