Perceptron
Perceptrons are the basis of neural networks. They exist to perform classifications like that shown below. Each dot represents the test scores and grades for set of students applying to a university. Blue dots indicate the student was accepted to the university. Red indicates they were denied.
In the case of the dot in yellow, above, we would assume they were accepted given that they are above the black dividing line.
The formula for the black line is given by:
Algorithmically, we could assign each applying student a score based on the following formula:
- If score > 0, the student is Accepted.
- If score < 0, the student is Denied.
In the example student above (Test = 7, Grades = 6), their score comes out to 2, which means they would be Accepted.
General Form for 2 Dimensions
The more general equation for a 2-dimensional boundary line is the following.
This can also be expressed as
The goal of the algorithm is to have
More General Case
The more general case exists in
To satisfy this equation, the weights,
Perceptron
A perceptron is an encoding of our equation above into a small graph. The perceptron receives the points as inputs, like in the image below, and returns
The bias can be thought of as another input with magnitude 1 and edge weight equal to the bias term, as show below.
In the case of the example above:
Since
The more general case of a perceptron with
During the linear function part of the node above, the node calculates
Perceptrons as Logical Operators
By setting the weights and bias strategically, perceptrons can be made to function as logical operators. The perceptron below functions as an AND
operator.
This one functions as an OR
.
A perceptron that models NOT
can also be constructed. Combinations of AND
, OR
, and NOT
perceptrons can be used to create more complicated logical operators such as NAND
and XOR
.
Perceptron Trick
The perceptron trick involves moving the line progressively closer to any misclassified points. For example, in the following image the point
To adjust the location of the line, it is adjusted by a small rate-limiting factor (“learning rate”) times the location of the point, with a 1 added as the bias. The line
Thus, the new equation for the line is
Perceptron Algorithm
-
Start with random weights:
-
For every misclassified point
:2.1. If prediction = 0:
- For i = 1 … n:
- Change
- Change
- Change
2.2 If prediction = 1:
- For i = 1 … n:
- Change
- Change
- Change
- For i = 1 … n: