TensorTau PathToAGI Neural Networks from First Principles Level 06

Level 06 · Neural Networks from First Principles · Chapter 080

XOR: Why Linear Models Fail

Can one tiny four-point problem prove that a single linear decision boundary is fundamentally insufficient?

XOR has four inputs:

x1 x2 | y
0  0  | 0
0  1  | 1
1  0  | 1
1  1  | 0

Plot them:

x2 ↑
1   ●(0,1)      ○(1,1)
0   ○(0,0)      ●(1,0)
    0-----------1 → x1

No single straight line can put both black points on one side and both white points on the other.

1. Why stacking linear layers does not help

Suppose

h=W1x+b1,h=W_1x+b_1,

y=W2h+b2.y=W_2h+b_2.

Substitute:

y=W2(W1x+b1)+b2=(W2W1)x+(W2b1+b2).y=W_2(W_1x+b_1)+b_2=(W_2W_1)x+(W_2b_1+b_2).

That is still just one affine transformation.

Ten linear layers without nonlinear activations collapse into one linear layer.

2. ReLU changes the algebra

Now insert

h=ReLU⁡(W1x+b1).h=\operatorname{ReLU}(W_1x+b_1).

We can no longer combine W2W_2 and W1W_1 into one matrix because ReLU changes behaviour depending on which region the input occupies.

A hidden layer can create two boundaries, isolate the middle XOR region, and let the output combine those hidden features.

3. The conceptual breakthrough

A hidden neuron need not mean “dog” or “cat.” It can learn an intermediate feature such as

“the point lies beyond this boundary.”

Another hidden neuron learns a different boundary. The output neuron recombines these new coordinates.

This is representation learning in miniature.

What to Remember

  • XOR is not linearly separable.
  • Repeating linear transformations without nonlinearity remains linear.
  • Hidden nonlinear units create features that make the final task easier.

Next → Hidden Layers: how should we think about the intermediate representations that appear between raw input and final prediction?

Six ways to work the chapter, climbing from explaining it in your own words to investigating it like a researcher. Reading is not enough — this is where the chapter lands.

  1. Explain: Why can no line solve XOR?
  2. Calculate: Show algebraically that two affine layers collapse to one.
  3. Predict: What happens if every activation is replaced by identity?
  4. Break: Train a one-layer linear classifier on XOR.
  5. Build: Train a 2-layer ReLU network on XOR and visualize its decision surface.
  6. Investigate: Find the smallest hidden width that reliably learns XOR across multiple seeds.