SC_Practical_1
SC_Practical_1
1
Aim:- Generate AND, OR and NOT functions using McCulloch-Pitts
neural net
def mcculloch_pitts_gate(gate_type, w1, w2=None, theta=0):
if gate_type == "and":
x1 = [1, 1, 0, 0]
x2 = [1, 0, 1, 0]
target_output = [1, 0, 0, 0]
x1 = [1, 1, 0, 0]
x2 = [1, 0, 1, 0]
target_output = [1, 1, 1, 0]
x1 = [1, 0]
target_output = [0, 1]
x2 = [0] * len(x1)
else:
return
y = [0] * len(target_output)
con = True
while con:
for i in range(len(target_output)):
y[i] = 1
else:
y[i] = 0
if y == target_output:
con = False
else:
break
print("Weights of neuron:")
if w2 is not None:
print("\nTesting OR Gate:")
Output:-