How does a perceptron learn?

One prediction, one error, one update. Watch two weights and a bias draw a boundary between two classes.

Interactive lab

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₂TargetzPrediction

The learning rule

z = w₁x₁ + w₂x₂ + b
ŷ = 1 if z ≥ 0 ; otherwise 0
e = y − ŷ
wᵢ ← wᵢ + η e xᵢ ; b ← b + η e

No update when the prediction is correct. One epoch is one pass over the 20 samples.

Things to explore

  1. Step through the samples: when do weights change?
  2. Watch the bias: how does it shift the line?
  3. 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 →