Deep Learning · TEE · section

Why XOR needs more than one perceptron

Neural-network foundations

XOR outputs 1 for [0,1] and [1,0], but 0 for [0,0] and [1,1]. On a graph the positive points occupy opposite corners. A single straight line cannot put both positive points on one side and both negative points on the other. A single perceptron has only one linear decision boundary.

XOR needs a combination of boundaries Tap the diagram to enlarge.

A two-layer construction solves it. Let h₁ = step(x₁ + x₂ − 0.5), which is OR. Let h₂ = step(x₁ + x₂ − 1.5), which is AND. With step(z) = 1 for z ≥ 0, output XOR = step(h₁ − 2h₂ − 0.5). Output XNOR = step(−h₁ + 2h₂ + 0.5).

x₁ x₂h₁ ORh₂ ANDXOR netXORXNOR
0 000−0.501
0 1100.510
1 0100.510
1 111−1.501

More layers help only if appropriate nonlinearities are used. Two purely affine layers collapse into one affine map: W₂(W₁x + b₁) + b₂ = (W₂W₁)x + W₂b₁ + b₂. Affine means linear plus a bias.