How does a perceptron learn?
One prediction, one error, one update. Watch two weights and a bias draw a boundary between two classes.
Learning a decision boundary
Completed epochs0
Samples processed0
Current errors0
Current accuracy0%
● Class 0◆ Class 1— Learned boundary◯ Selected sample
Understanding the last step
The step’s prediction and error use weights before the update. The plot, inspector and accuracy use the current weights.
All samples and their predictions
| # | x₁ | x₂ | Target | z | Prediction |
|---|
The learning rule
z = w₁x₁ + w₂x₂ + b
ŷ = 1 if z ≥ 0 ; otherwise 0
e = y − ŷ
wᵢ ← wᵢ + η e xᵢ ; b ← b + η eNo update when the prediction is correct. One epoch is one pass over the 20 samples.
Things to explore
- Step through the samples: when do weights change?
- Watch the bias: how does it shift the line?
- Reset and change η. Compare the path taken by the boundary.
A perceptron can converge on linearly separable data. It cannot represent XOR with these inputs alone. Explore the multilayer perceptron →