Skip to content
AI360XpertBeta
Core ML

Visual explainer

Perceptron

Follow two checked mistake updates from a zero start to a straight separator, then see why one neuron cannot represent XOR.

One straight boundary can separate these four labelled inputs.
One straight boundary can separate these four labelled inputs.

A perceptron learns a straight decision boundary by correcting classification mistakes. The filled circles are class 0 and the outlined squares class 1. Our synthetic, dimensionless training rows are A = (−1, −1): 0, B = (−1, 1): 0, C = (1, −1): 1 and D = (1, 1): 1. A vertical cut can separate them; training must find its weights and bias.

Form a Signed Score

Signed weighted contributions combine into a score.
Signed weighted contributions combine into a score.

Each horizontal step adds one contribution; the vertical connectors only keep the additions in order. For row C, intermediate weights w = (1, 1) and bias b = −1 produce:

z=w1x1+w2x2+b=1(1)+1(−1)−1=−1.z = w_1x_1+w_2x_2+b = 1(1)+1(-1)-1=-1.

Predict 1 when z ≥ 0, otherwise 0. A zero score predicts 1 throughout this page. These scores are not probabilities. Geometric signed distance is z divided by the weight-vector length when that length is nonzero.

Correct a False Positive

A false positive subtracts the input and lowers the bias.
A false positive subtracts the input and lowers the bias.

Now start training at w = (0, 0), b = 0 and learning rate η = 1. Visit A, B, C, D in that order. A has score zero, so the model predicts 1 although its label is 0. The error y − ŷ is −1. The binary-label form of the perceptron update is:

w←w+η(y−y^)x,b←b+η(y−y^).w \leftarrow w+\eta(y-\hat y)x,\qquad b\leftarrow b+\eta(y-\hat y).

Subtracting A = (−1, −1) gives w = (1, 1), b = −1. The arrow is movement in weight space, with a separate lane for bias. A's score becomes −3. A mistake correction need not preserve every other prediction or repair an arbitrarily large error in one step.

Correct a False Negative

A false negative adds the input and raises the bias.
A false negative adds the input and raises the bias.

B now scores −1 and is correct. C also scores −1, but needs label 1. Adding C = (1, −1) gives w = (2, 0); raising bias by 1 gives b = 0. C's new score is 2. The final row D scores 2 and needs no update. There are exactly two mistake updates in this chosen scan, not four hypothetical pivots.

Read the Learned Cut

The learned vertical cut classifies all four training rows.
The learned vertical cut classifies all four training rows.

The dashed cut was x₁ + x₂ − 1 = 0. The solid learned cut is 2x₁ = 0. The horizontal normal vector points toward increasing score; its schematic arrow length does not encode a score. The four scores are now −2, −2, 2 and 2, so all four labels match. Feature axes and point locations match the opening scene.

Scale the Same Updates

Scaling every update can leave the classifier unchanged.
Scaling every update can leave the classifier unchanged.

Repeat the same order from zero with constant η = 0.1. The two states become (0.1, 0.1), b = −0.1 and then (0.2, 0), b = 0. Each score is a positive tenth of the η = 1 score, preserving its sign and ties. The arrows share one weight scale and differ tenfold in length.

This equivalence assumes zero initialization, a constant positive learning rate, the same sample order and the same tie rule. It shows why reducing the step alone does not make overlapping labels separable. It does not establish that large steps minimize training passes.

Examine a Boundary Tie

A zero score follows the tie rule and can be fragile.
A zero score follows the tie rule and can be fragile.

This is an explicit local zoom: 1,000 drawing units per x₁ unit, with x₂ held at 0.5. At (0, 0.5), score zero predicts 1 by convention. Moving x₁ to −0.05 gives score −0.1 and prediction 0. A tie decision is not evidence of high confidence, and this example has no probabilistic confidence model.

Check an Entire Pass

A full error-free pass leaves the parameters unchanged.
A full error-free pass leaves the parameters unchanged.

A second complete scan produces no mistakes, so neither weights nor bias change. A single correct row would not establish that. Finite convergence relies on a finite, linearly separable dataset; the usual margin argument includes the bias by appending a constant input coordinate. Convergence finds a separator, with no guarantee of maximum margin or fresh-data accuracy.

Try a Fresh Input

The same rule classifies a fresh point by its side.
The same rule classifies a fresh point by its side.

The diamond is a new input (0.25, −0.5), on the original feature scale. The learned score is 2 × 0.25 = 0.5, so prediction is 1. The short projection identifies its side of the cut. It is a prediction exercise, not a measured generalization result: a true label would still need observing.

Where It Breaks

Opposite XOR corners cannot be separated by one line.
Opposite XOR corners cannot be separated by one line.

Change the labels on the same signed square: opposite corners now share a class. The diagonals connect same-class points and intersect at their common midpoint. An affine score at a midpoint equals the average of its endpoint scores. The class-0 diagonal would require a negative midpoint score; the class-1 diagonal would require a nonnegative one. Both cannot hold.

One straight threshold therefore cannot fit all four XOR labels, however long training runs. Nonlinear hidden features, as in the multi-layer perceptron visual, add representational capacity at the cost of more parameters and a harder optimization problem.

The Quick Version

  • Signed weighted inputs and bias produce the decision score.
  • Zero predicts one under this page's explicit tie convention.
  • A false positive subtracts its input and lowers bias.
  • A false negative adds its input and raises bias.
  • Two checked updates separate this synthetic training set.
  • Constant learning-rate scaling can preserve every prediction.
  • Boundary ties can flip under small input changes.
  • A complete error-free pass leaves all parameters unchanged.
  • Fresh predictions still require observed labels for evaluation.
  • Opposite XOR corners exceed one straight threshold's capacity.