예제 #1
0
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))
예제 #2
0
Xor = XOR()
Xor.train()

' Test cases for 4 Gates for 1D Input'

# Test cases for AND
print(
    "\nDemonstrating AND Gate functionality using FeedForward Neural Network")
print("And(False, False) = %r" % And.forward(False, False))
print("And(False, True) = %r" % And.forward(False, True))
print("And(True, False) = %r" % And.forward(True, False))
print("And(True, True) = %r" % And.forward(True, True))

# Test cases for OR
print("\nDemonstrating OR Gate functionality using FeedForward Neural Network")
print("Or(False, False) = %r" % Or.forward(False, False))
print("Or(False, True) = %r" % Or.forward(False, True))
print("Or(True, False) = %r" % Or.forward(True, False))
print("Or(True, True) = %r" % Or.forward(True, True))

# Test cases for NOT
print(
    "\nDemonstrating NOT Gate functionality using FeedForward Neural Network")
print("Not(False) = %r" % Not.forward(False))
print("Not(True) = %r" % Not.forward(True))

# Test cases for XOR
print(
    "\nDemonstrating XOR Gate functionality using FeedForward Neural Network")
print("Xor(False, False) = %r" % Xor.forward(False, False))
print("Xor(False, True) = %r" % Xor.forward(False, True))