Learning Machines W3 HW: Perceptron Implementation

This week’s homework was to implement the Perceptron algorithm and train it on data sets based on the AND, OR, and XOR logic gates. Since the outputs we want the Perceptron to predict are known, this is considered supervised training. Here is my spaghetti code:

This code returns the results once its predictions match the known outputs. I had it print each step to see what it was thinking:

AND results

OR results

Then, as expected, my Perceptron was not able to reach 100% accuracy for the XOR dataset, and thus does not exit the loop. Here it is trying very hard:

Full code here: https://github.com/xujenna/learning_machines/blob/master/perceptron.py

Leave a Reply

Your email address will not be published. Required fields are marked *