XOR and the first AI winter
Last updated
One neuron draws one straight line, and XOR needs more than one. In 1969 Marvin Minsky and Seymour Papert made that limit, and others like it, precise in a book called Perceptrons, and money and interest drained out of neural networks for over a decade. This lesson looks at what the book really showed and what was read into it, solves XOR with two layers by hand, finds out why the second layer must bend, and follows the road from 1943 to the 1986 rule that trains many layers.
By the end of this lesson you can
- Show that no single neuron computes XOR, and that the perceptron never settles on it
- Say what Minsky and Papert proved, and what was overstated afterwards
- Build a two-layer network that computes XOR, by hand
- Explain why stacking linear layers gives only another linear layer
XOR on a plane
Lesson 5.1 found that no single unit computes XOR, by trying almost 5,000 settings. Here's why, as a picture: put the four inputs at the corners of a square. XOR is true at (0, 1) and (1, 0), and false at (0, 0) and (1, 1). A neuron fires on one side of a straight line. To have both true corners on one side and both false corners on the other, the line would have to cross the square twice. It can't.
What does the perceptron do, given XOR to learn?
4 mistakes in every epoch, for as long as you let it run: each nudge that fixes one corner spoils another, round and round. It's lesson 5.2's non-separable data at its smallest.
Perceptrons (1969)
By the late 1960s, Rosenblatt and others had built bigger perceptrons and made big claims for them. Marvin Minsky and Seymour Papert, at MIT, set out to find what perceptrons could actually compute, and in 1969 published the answer as a book, Perceptrons.
It was careful mathematics. Their perceptrons had one layer of adjustable weights, fed by fixed "feature detectors" that each looked at part of the input, like a few pixels of an image. They proved that some simple-sounding questions can't be answered that way unless some detectors look at the whole input at once. Two examples:
- Parity: is the number of pixels switched on odd or even? XOR is parity for two inputs. For an image, every detector would need to see every pixel.
- Connectedness: is the shape in the picture one piece, or more than one? A local view can't tell.
The book was a hit, and its timing was bad for neural networks. Over the next years, research money in the US went mostly to symbolic AI, programs built from rules and logic. Rosenblatt died in a boating accident in 1971. Work on neural networks didn't stop, but it shrank to a few groups for over a decade: the first AI winter for neural networks, part of a wider cooling towards AI in the 1970s.
What they showed, and what was overstated
The book proved true things about one layer of adjustable weights. It didn't prove, and didn't claim to prove, that networks can't do XOR. McCulloch and Pitts had shown in 1943 that a network of two layers computes it, and everyone in the field knew.
The real gap was different: nobody had a way to learn the weights of the units in the middle, the hidden units, whose right answers aren't given by the data. The perceptron rule needs a target for every unit's output, and a hidden unit has none. Minsky and Papert doubted that a learning rule for many layers would be found, or would be worth much. That was a guess, not a theorem, and it turned out wrong.
Over the years the story grew in the retelling, into "a book proved neural networks were a dead end" (Olazaran, 1996, traces how). The fairer summary: one layer really is limited; more layers aren't; and the missing piece was a training rule for hidden layers, which arrived in the 1980s.
Two layers solve XOR, by hand
XOR is "OR, but not AND". So use two units in a hidden layer, one computing OR and one AND, and an output unit that fires when OR is on and AND is off:
Here is 1 when and 0 otherwise, and each bias is minus a threshold (lesson 5.2). In NumPy:
is 0, 1, 1, 1: OR. is 0, 0, 0, 1: AND. And the output is 0, 1, 1, 0: XOR.
Why does it work? The hidden layer moves the points. In terms of , the four inputs land on only three spots: (0, 0) stays at (0, 0), both (0, 1) and (1, 0) go to (1, 0), and (1, 1) goes to (1, 1). The two true cases are now in the same place, and a single line, , separates them from the rest. Watch the plane fold:
The inputs: XOR's two circles sit on opposite corners, and no straight line separates them from the squares. Move the slider.
That's the whole idea of a neural network with hidden layers: each layer moves the data into a new space where the next layer's job is easier, until, at the end, one straight line is enough. Here the hidden layer was designed by hand. In Stage 6 it will be learned.
Wrong way: adding a second linear layer
The hidden units above use a step. What if they didn't? Take the same network with the steps removed, so each layer only computes a weighted sum, and multiply it out:
The two-layer network outputs 0.5 for every input, and so does a single layer with weights , which are (0, 0). It's the same function. That isn't a coincidence of these numbers: a linear layer after a linear layer is always one linear layer, because
Matrix multiplication is associative (lesson 1.4), so any number of linear layers collapses into one, and one layer is a straight line. In the figure in step 4, choose "Steps taken out": the grid stays straight and gets squashed onto a line, with XOR's points on it in the order square, circle, square. No line separates them.
So the nonlinearity between layers is what makes depth worth anything. The step, the sigmoid (lesson 5.5), and the functions Stage 6 will use all bend the space; without them, a network of a hundred layers is a perceptron.
From 1943 to 1986
1943: model neuron. McCulloch and Pitts describe a threshold unit, and show that networks of them can compute any logical function (lesson 5.1). The weights are set by hand.
The rule that broke the winter, backpropagation, is the chain rule (lesson 1.7) applied to a network: it works out how much each hidden weight contributed to the error by passing the error backwards, layer by layer. It needs every unit to have a slope, which is why networks swapped the step for smooth activations like the sigmoid. With it, a network learns its own hidden layer:
scikit-learn's MLPClassifier, a multi-layer perceptron, with one hidden layer of 4 units, learns XOR from the four examples: . How it does that is Stage 6.
Check what you learned
Sources
Every example on this page was run with Python 3.14, and its output and error messages are copied from it. These pages cover the same ground in more depth.
- Minsky and Papert, Perceptrons: An Introduction to Computational Geometry, MIT Press, 1969 (reissued 2017): what one layer of perceptrons can and can't compute
- Olazaran, A sociological study of the official history of the perceptrons controversy, Social Studies of Science 26(3), 1996: what the book said, and how the story of it grew
- Rumelhart, Hinton and Williams, Learning representations by back-propagating errors, Nature 323, 1986: training hidden layers, the way out
- Goodfellow, Bengio and Courville, Deep Learning, section 6.1: Example: Learning XOR: XOR with a hidden layer, and why the hidden layer must be nonlinear