We have seen that a perceptron draws a straight line. So what kind of function can it never compute?
XOR
XOR (exclusive or) outputs 1 when exactly one input is 1:
| XOR | ||
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Plot the four points. The two 1-outputs are at opposite corners of the square, and so are the two 0-outputs. There is no straight line with both 1-corners on one side and both 0-corners on the other.
Try to find a line that classifies all four points. Then see what changes when a second layer is added.
The algebra agrees
Suppose some did compute XOR. The four rows would require:
Add rows 2 and 3: , so . Row 4 says .
Together, , which forces , that is, . But row 1 says . Contradiction, so no such weights exist. No learning algorithm can find them either.
How common is this?
Two binary inputs give possible Boolean functions. Of these, 14 are linearly separable, and only XOR and its opposite XNOR are not. So the failure is rare among two-input functions. It becomes far more common as inputs grow.
In general, binary inputs give possible input rows, and each row can output 0 or 1, so there are Boolean functions. That is 16 for , 256 for , and over 4 billion for . How many of them are linearly separable has no simple formula. Counting them is a hard problem that researchers have worked out only for small . What we can say is that some are not separable, and that is enough to need something more than one perceptron.
Real data rarely separates cleanly
The film example has the same flavour. Real preferences are messy: you might like a thriller only when it is by a particular director, or a comedy only when a certain actor is in it. Interactions like this are exactly what a single straight line cannot capture. A dataset of past films will usually not be linearly separable.
Two common reasons:
- Outliers. Among people who fit the profile of someone who enjoys machine learning, a few still do not. Among the people of one neighbourhood who mostly speak one language, a few speak another.
- Genuinely curved boundaries. Picture one group forming an inner ring and another an outer ring around it. There are no outliers at all, yet no straight line separates them.
On non-separable data, the perceptron learning algorithm never reaches a clean pass. It keeps correcting forever. A single perceptron is simply too weak for such problems.
A way out
The problem was not perceptrons. It was using one. Stacking several perceptrons, where some feed into another, changes what can be computed. The next lesson shows a network that solves XOR and, in fact, any Boolean function.