A ReLU network is piecewise linear
proof▲▲△Prove that a network with ReLU activations computes a piecewise-linear function of its input, and that the pieces are convex polytopes. Then bound the number of pieces for a network with layers of units each, and say what that bound does and does not tell you.
Hint
Fix which units are active. What does the network compute then?
Solution
Step 1 — fix an activation pattern. For a given input, each ReLU unit is either active (, passing ) or inactive (, passing ). Record this as a binary pattern , one bit per unit.
Step 2 — the network is affine on each pattern’s region. Hold fixed. Then every ReLU is replaced by either the identity or the zero map, both linear. The network becomes a composition of affine maps, which by I.3.B05 is a single affine map . So on the set of inputs producing pattern , the network is exactly affine.
Step 3 — the regions are convex polytopes. Each unit’s condition is or — a half-space in , provided its inputs are affine in , which they are once the earlier layers’ patterns are fixed. A region is the intersection of half-spaces, and an intersection of half-spaces is a convex polytope.
Step 4 — counting. Naively there are patterns, but almost all are unrealisable: with units in the first layer over a -dimensional input, the number of regions hyperplanes cut into is , not . Composing layers gives the standard bound
which is exponential in depth and polynomial in width. That asymmetry is the usual formal argument for depth: to match a depth- network’s region count, a shallow one needs width exponential in .
What the bound does not tell you. Three things, and they matter.
It counts pieces, not usefulness. A function can have linear pieces and be a poor model. Region count is a capacity measure, and I.1.T2 already warned that capacity is not accuracy.
It is an upper bound, and trained networks are far below it. Empirically the number of regions a trained network actually uses is orders of magnitude smaller than the bound, and grows roughly linearly rather than exponentially with depth.
It says nothing about optimisation. The regions exist in the hypothesis class whether or not gradient descent can arrange them usefully — the same gap I.3.T2 flags for universal approximation.
A consequence worth keeping. Since the network is affine on each region, it is differentiable on the interior of each region and non-differentiable only on the boundaries, which form a measure-zero set. That is why training works at all despite ReLU having no derivative at its kink: the probability of landing exactly on a boundary is zero, and the subgradient convention of I.2.X09 covers the rest.