Simple Perceptron implementation
Simple Perceptron implementation
An implementation of a simple perceptron, based on the tutorials (1 and 2) from The Coding Train by Daniel Shiffman.
A more complete and detailed answer to this question can be obtained by watching the tutorials linked above.
A line is created inside a cartesian plane, following the y=mx+b
equation.
Then, a number of points are scattered across the plane, in a random fashion. The perceptron then starts adjusting its weights by asking each point if it appears on one side (black dots) or the other (white dots) from the line.
Using this simple logic, the perceptron can find the original line’s parameters in (usually) several thousands of iterations. Of course, the number of points will greatly affect the final accuracy of the “deduced” line.
Please note that some parameters in the implementation have been intentionally altered to enhance the experience of watching the algorithm work, by slowing it down.
The legend on the top/left corner displays the following information:
Each dot (represented by a 16x16 circle) uses four colors to represent six different states: