Last active
April 23, 2017 14:40
-
-
Save imjacobclark/a23e29fa11d51b547eef76644f729d37 to your computer and use it in GitHub Desktop.
A single layer neural network to determine AND boolean logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nn(input1, input2): | |
bias = 1 | |
weight0 = -1 | |
weight1 = 0.5 | |
weight2 = 0.5 | |
net = (bias*weight0)+(input1*weight1)+(input2*weight2) | |
return "1" if net >= 0 else "0" | |
print "X | Y | O " | |
print "0 | 0 | " + nn(0, 0) | |
print "1 | 0 | " + nn(1, 0) | |
print "0 | 1 | " + nn(0, 1) | |
print "1 | 1 | " + nn(1, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment