Skip to content

Instantly share code, notes, and snippets.

@suzuken
Created September 24, 2012 13:00
Show Gist options
  • Save suzuken/3775826 to your computer and use it in GitHub Desktop.
Save suzuken/3775826 to your computer and use it in GitHub Desktop.
Threshold Logic Unit
class TLU:
def __init__(self, threshold, weights):
self.threshold = threshold
self.weights = weights
pass
def fire(self, inputs):
t = 0
t = sum([self.weights[i] for i in range(len(self.weights)) if inputs[i] is True])
return t > self.threshold
a = TLU(1, [1,2,3])
print a.fire([True,False,True])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment