Interactive notebook
A Net Learns XOR
The moment a hidden layer invents the feature that makes the problem linear.
Not linearly separable — needs the hidden layer.
The network
Edge thickness = |weight|. Red is positive, blue negative.
What it computes
Loss
Truth table
| x₁ x₂ | target | predicted | result |
|---|---|---|---|
| 0 0 | 0 | 0.641 | ✗ |
| 0 1 | 1 | 0.745 | ✓ |
| 1 0 | 1 | 0.619 | ✓ |
| 1 1 | 0 | 0.732 | ✗ |
Press Run. Watch the hidden-layer weights first: nothing much happens, then suddenly everything does.
XOR is the classic proof that one layer isn’t enough: no single straight line separates (0,1) and (1,0) from (0,0) and (1,1). The two hidden units each learn a line, and the output unit combines them — which is why the finished decision surface has a corner in it. Try a few different random inits: some runs solve it in a few hundred epochs, some stall for thousands, and that variance is a real property of training, not a bug in the demo.