The tiny logic puzzle that stalled neural networks, and the hidden layer that solved it.
XOR looks like the easiest problem in the world. It has two inputs, four cases, and a one-line rule. Yet a single artificial neuron cannot learn it, no matter how long you train it.
Understanding why takes one picture. And the fix explains why every modern neural network has hidden layers.
What XOR does
XOR stands for "exclusive or." It outputs 1 when exactly one of its two inputs is 1.
- 0 and 0 give 0.
- 0 and 1 give 1.
- 1 and 0 give 1.
- 1 and 1 give 0.
So it's "one or the other, but not both."

The XOR truth table. The output is 1 only when the two inputs differ.
Put the four cases on a grid
Now plot each case as a point, with the first input across and the second input up. Color the points by their answer: blue for 1, hollow for 0.
The two 1s sit on one diagonal. The two 0s sit on the other diagonal.
One neuron, one straight line
A single neuron (a perceptron) decides by drawing one straight line. Everything on one side gets a 1, and everything on the other side gets a 0.
Try to place that line for XOR:
- A vertical line catches one of the 1s, but also a 0.
- Turn it into a diagonal, and it catches both 1s, but still grabs a 0.
Wherever you put it, the line mixes the classes. No straight line can separate them. Problems where one line does work are called "linearly separable." XOR is not.

However you draw a single straight line, it puts a 0 on the same side as the 1s.
The book that cooled the field
In 1969, Marvin Minsky and Seymour Papert proved this limit in their book Perceptrons. They showed that single-layer perceptrons can't compute functions like XOR.
The result helped cool interest in neural networks for years. Research slowed until people had practical ways to train networks with more than one layer.
The fix: a hidden layer
The answer is to add a layer of neurons between the inputs and the output. It's called a hidden layer because you never see its values directly.
For XOR, two hidden neurons are enough:
- The first neuron asks: is at least one input on? That's OR.
- The second neuron asks: are they not both on? That's NAND ("not and").
- The output neuron fires only when both answers are yes. That's AND.
Check it: for inputs 1 and 0, OR says yes and NAND says yes, so the output is 1. For 1 and 1, OR says yes but NAND says no, so the output is 0.

A hidden layer solves XOR: OR and NAND feed an AND output.
Two lines make a band
Here's what that looks like on the grid. Each hidden neuron draws its own straight line. Together, the two lines fence off a diagonal band, and both 1s land inside it.
One neuron gives you one line. A layer of neurons gives you many lines, and the next neuron can combine them into shapes. That's the core reason deep networks have layers.

The OR line and the NAND line fence off a band that holds both 1s and neither 0.
Quick check
One neuron draws one straight line. Which can it learn: the AND gate, or the XOR gate?
Answer: AND. AND outputs 1 only for the input (1, 1). That single point sits in a corner, so one straight line can cut it off. XOR needs two.
Key takeaways
- XOR outputs 1 when exactly one input is 1.
- A single neuron draws one straight line, and no straight line separates XOR's 1s from its 0s.
- Minsky and Papert proved this limit in 1969, which slowed neural network research for years.
- A hidden layer fixes it: OR and NAND draw two lines, and AND combines them into a band.
This article is part of Deep Learning, Visually by Logit Solutions AI: short animated explainers that cover one idea at a time, each with a written version like this one.
Top comments (0)