[go: up one dir, main page]

0% found this document useful (0 votes)
371 views3 pages

Experiment-6: AIM-Write A Program To Implement XOR Gate Using Mcculloch-Pitts Neuron. Program

The document describes a program that implements an XOR gate using a McCulloch-Pitts neuron model. The program takes in weight and threshold values as input, calculates the outputs of intermediate neurons Z1, Z2 and the final neuron Y, and iterates until the output Y matches the expected output Z. It then displays the weights and threshold value that allowed the neural network to learn the XOR function.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
371 views3 pages

Experiment-6: AIM-Write A Program To Implement XOR Gate Using Mcculloch-Pitts Neuron. Program

The document describes a program that implements an XOR gate using a McCulloch-Pitts neuron model. The program takes in weight and threshold values as input, calculates the outputs of intermediate neurons Z1, Z2 and the final neuron Y, and iterates until the output Y matches the expected output Z. It then displays the weights and threshold value that allowed the neural network to learn the XOR function.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

EXPERIMENT-6

AIM- Write a program to implement XOR gate using Mcculloch-Pitts neuron.

PROGRAM-
% XOR function using McCulloch-Pitts neuron model
clear;
clc;
%Getting weights and threshold value
disp('Enter weights');
w11=input('Weight w11=');
w12=input('weight w12=');
w21=input('Weight w21=');
w22=input('weight w22=');
v1=input('weight v1=');
v2=input('weight v2=');
disp('Enter Threshold Value');
theta=input('theta=');
x1=[0 0 1 1];
x2=[0 1 0 1];
z=[0 1 1 0];
con=1;
while con
zin1=x1*w11+x2*w21;
zin2=x1*w21+x2*w22;
for i=1:4
if zin1(i)>=theta
y1(i)=1;
else
y1(i)=0;
end
if zin2(i)>=theta
y2(i)=1;
else
y2(i)=0;
end
end
yin=y1*v1+y2*v2;
for i=1:4
if yin(i)>=theta;
y(i)=1;
else
y(i)=0;
end
end
disp('Output of Net');
disp(y);
if y==z
con=0;
else
disp('Net is not learning enter another set of weights and Threshold value');
w11=input('Weight w11=');
w12=input('weight w12=');
w21=input('Weight w21=');
w22=input('weight w22=');
v1=input('weight v1=');
v2=input('weight v2=');
theta=input('theta=');
end
end
disp('McCulloch-Pitts Net for XOR function');
disp('Weights of Neuron Z1');
disp(w11);
disp(w21);
disp('weights of Neuron Z2');
disp(w12);
disp(w22);
disp('weights of Neuron Y');
disp(v1);
disp(v2);
disp('Threshold value');
disp(theta);

OUTPUT-
Enter weights

Weight w11=2

weight w12=-1

Weight w21=-1

weight w22=2

weight v1=2

weight v2=2

Enter Threshold Value

theta=2

Output of Net

0 1 1 0

McCulloch-Pitts Net for XOR function


Weights of Neuron Z1

-1

weights of Neuron Z2

-1

weights of Neuron Y

Threshold value

>>

You might also like