Lesson 2.3 · 8 min read · about 55 min to master at a very slow pace

The XOR Problem

A proof that no single neuron can compute XOR, what happens when you try to train one anyway, and two ways out: hand-made features or a hidden layer.

Not startedJump to quiz

The impossibility proof

XOR is positive for and and negative for and . Suppose one neuron with weights and bias classified all four correctly. Then:

InputClassRequirement
(0, 0)negative
(1, 1)negative
(1, 0)positive
(0, 1)positive
  • Adding the two positive rows: .
  • Adding the two negative rows: .

The same number can't be both positive and negative, so no such exist. No single neuron with a linear decision boundary can compute XOR.

Why it matters

This is a proof of impossibility, not a failed training run. No amount of training, data or learning-rate tuning will make one neuron solve XOR.

What training does anyway

Train a single sigmoid neuron on XOR with mean squared error and it gets stuck: every output settles near 0.5 and the loss at 0.25. With targets 0 and 1, predicting 0.5 everywhere gives : the best a straight boundary can do is refuse to decide.

Way out 1: hand-made features

XOR can be written as . If you add the feature as a third input, XOR is linear in and one neuron can solve it. But this needs someone to design the right feature.

Way out 2: a hidden layer

A network with a hidden layer can learn a useful representation itself. Section 3 builds an explicit 2–2–1 network for XOR: its hidden units compute OR and AND, and the output combines them. That is the core idea of deep learning: layers learn the features.

Stuck? Common doubts

Questions real learners asked while studying this lesson. They stay closed so they don't spoil your own thinking: open only the ones you need.

First passIs XOR unsolvable because we did not train long enough?

No. The inequalities show that no weights work, so this is about what one neuron can represent, not about training. A failed training run could be bad luck; a contradiction in the inequalities is a proof.

Going deeperWhy does the trained neuron output exactly 0.5 for every input?

With MSE and targets 0 and 1, each pair of opposite corners pulls the boundary in opposite directions and they cancel. The point that minimises the squared error when no boundary can separate the classes is to predict the mean target, 0.5, everywhere, giving loss .

Cheatsheet

XOR proof in one line

Positives give ; negatives give . Contradiction, so one neuron cannot solve XOR.

Two ways to solve XOR

Add the feature (XOR ), or add a hidden layer that learns the representation.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1conceptIn the proof that one neuron can't compute XOR, what contradiction do the four inequalities produce?
Q2interpretYou train a single sigmoid neuron on XOR with MSE. The loss stalls at 0.25 and every output is about 0.5. What does this mean?
Q3calculateXOR can be written as . What does it give for ?
Q4applyYou add the product as a third input to a single neuron. Can it now compute XOR?
Q5conceptWhy is the XOR result described as a proof rather than an experimental finding?