Last active
August 29, 2015 14:13
-
-
Save jonathanmarvens/cef6ebd30c3c6444a890 to your computer and use it in GitHub Desktop.
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
class BasicPerceptron(object): | |
def __init__(self, weights, bias): | |
self.weights = weights | |
self.threshold = bias * -1 | |
def run(self, inputs): | |
input_weight_pairs = zip(inputs, self.weights) | |
sum_ = 0.0 | |
for input_, weight in input_weight_pairs: | |
sum_ += input_ * weight | |
return 0 if sum_ <= self.threshold else 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: