Skip to content

Instantly share code, notes, and snippets.

@tkc
Created November 7, 2016 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkc/db31528eacc3137ef8e702a9c5d4dac3 to your computer and use it in GitHub Desktop.
Save tkc/db31528eacc3137ef8e702a9c5d4dac3 to your computer and use it in GitHub Desktop.
def AND(x1, x2):
w1, w2, theta = 0.5, 0.5, 0.7
tmp = x1 * w1 + x2 * w2
if tmp <= theta:
return 0;
elif tmp > theta:
return 1;
if __name__ == '__main__':
print 'perceptron sample';
print AND(0, 0);
print AND(1, 0);
print AND(0, 1);
print AND(1, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment