Created
April 5, 2018 20:55
-
-
Save Thomascountz/baeecd8de6eb73f179d1342fd4519748 to your computer and use it in GitHub Desktop.
Using Perceptron in Python v. 1
This file contains 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
import numpy as np | |
from perceptron import Perceptron | |
training_inputs = [] | |
training_inputs.append(np.array([1, 1])) | |
training_inputs.append(np.array([1, 0])) | |
training_inputs.append(np.array([0, 1])) | |
training_inputs.append(np.array([0, 0])) | |
labels = np.array([1, 0, 0, 0]) | |
perceptron = Perceptron(2) | |
perceptron.train(training_inputs, labels) | |
inputs = np.array([1, 1]) | |
perceptron.predict(inputs) | |
#=> 1 | |
inputs = np.array([0, 1]) | |
perceptron.predict(inputs) | |
#=> 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment