i3=[False,True] print("The input sequence for testing is:") print("1.",i) print("2.",i1) print("3.",i2) print("4.",i3) print("Training of AND gate") a.train() print("Testing of AND gate") print(a.forward(i)) print(a.forward(i1)) print(a.forward(i2)) print(a.forward(i3)) print("Training of XOR gate") b.train() print("Testing of XOR gate") print(b.forward(i)) print(b.forward(i1)) print(b.forward(i2)) print(b.forward(i3)) print("Training of OR gate") c.train() print("Testing of OR gate") print(c.forward(i)) print(c.forward(i1)) print(c.forward(i2)) print(c.forward(i3)) print("Training of NOT gate") e.train() print("Testing of NOT gate") print(e.forward(i3))
# if mse >= .01: # wrong += 1 # else: # correct += 1 # print(wrong) # print(correct) # print(correct / (wrong + correct)) # exit() and_gate = AND() and_gate.train() or_gate = OR() or_gate.train() not_gate = NOT() not_gate.train() xor_gate = XOR() xor_gate.train() print("") print("AND GATE") print(and_gate(False, False)) print(and_gate(False, True)) print(and_gate(True, False)) print(and_gate(True, True)) print("AND GATE WEIGHTS")
print(nn.Theta) nn.updateParams(0.01) print(nn.Theta) # In[15]: And.train() print(And(True, True)) print(And(True, False)) print(And(False, True)) print(And(False, False)) # In[16]: Or.train() print(Or(True, True)) print(Or(True, False)) print(Or(False, True)) print(Or(False, False)) # In[17]: Not.train() print(Not(False)) print(Not(True)) # In[18]: Xor.train() print(Xor(True, True))