The depth at which a sigmoid stack stops passing gradient
limit▲▲▲Derivatives to 6 s.f.; products in scientific notation.
STATEMENT
Find the maximum of . Compute the product of ten sigmoid derivatives at . Then find the depth at which the product underflows fp16, both at and in the best case.
GIVEN
from I.3.B02. The smallest positive fp16 value is the subnormal (Floating point 0.NU.01). A gradient reaching layer of an -layer stack is multiplied by one per layer.
FIND
; the value of ; and the smallest with at and at .
STRATEGY
Maximise the derivative by treating it as a quadratic in rather than in — the substitution turns calculus into inspection. Then take logarithms to turn the repeated product into a linear count.
SOLUTION
Step 1 — the maximum. Let . Then , a downward parabola in with vertex at :
and means . So the best a sigmoid ever does for a gradient is divide it by four, and it does that only at one point.
Step 2 — the derivative at . , so
Fourteen times smaller than the best case, from a pre-activation that is not extreme — is entirely ordinary in an unnormalised network.
Step 3 — ten layers.
For comparison the best case gives . Even at every layer’s single most favourable point, ten layers cost six orders of magnitude.
Step 4 — the fp16 depth. Solve by taking logarithms:
At , , so , giving .
At , , so , giving .
What the two numbers say. A sigmoid network in fp16 has a hard ceiling of about twelve layers even under conditions that never occur — every unit sitting exactly at its most favourable point on every example. In realistic conditions, with pre-activations spread over a range including , the ceiling is five. Not “training is slow past five layers”: the gradient is exactly zero, because the product is not representable and rounds to it.
This is why deep networks were not trained before roughly 2010, and it is why three separate later chapters exist. ReLU (this chapter) removes the shrinking factor entirely for active units. Normalisation (I.8) keeps near the favourable region. Residual connections (II.6) provide a path with derivative exactly that no activation stands on.
Answer
fp16 underflow at depth for , and at depth in the impossible best case throughout.
Check — numeric · i-3-b03-saturation-depth.py
def dsigmoid(z): s = sigmoid(z); return s * (1.0 - s)
prod, L = 1.0, 0
while prod > 2.0 ** -24: prod *= g; L += 1Prints max sigma' 0.2500, sigma'(4)^10 2.955102e-18, and both depths.
Executed in CI. The digits above are the digits it printed.
Check — sanity
The maximum is attained where the function is symmetric. inherits , so : the derivative is even, and an even function’s extremum on sits at unless it is bimodal. Consistent.
The logarithmic estimate agrees with the loop. The closed form gave and the loop counted ; and the loop counted . Two methods, same answer.
The magnitudes bracket correctly. , since and both are raised to the same power. A product of smaller numbers must be smaller.
Where this breaks
The analysis assumes every layer’s derivative is the same, which it is not: real pre-activations vary per unit and per example, so the true product is a mix of factors. That makes the situation worse, not better — the product is dominated by its smallest factors, and a single saturated layer anywhere in the stack zeroes the whole path regardless of how favourable the others are.
The analysis also assumes fp16 without loss scaling. Multiplying the loss by before the backward pass shifts every gradient up by that factor and buys about four more layers, which is exactly what mixed-precision training does (II.8.B04). It buys layers; it does not remove the mechanism.
Variation
Repeat for tanh, whose maximum derivative is rather than . Find the fp16 depth at and state how many extra layers tanh buys over sigmoid — then say whether that is enough to matter.