Chain rule, one neuron deep: two ways a gradient vanishes
Five tanh layers, one neuron each: hl = wlal−1, al = tanh(hl), and the loss is just L = a5. The gradient that reaches a weight is a product of numbers read off this graph, so it collapses if any one factor is near zero: a flat slope (the unit is saturated), or a near-zero input (the product rule at a × node multiplies the gradient by the other input).
weight std σw1.00input x1.00
Each weight is σw times a fixed standard-normal draw, so the slider rescales the same network and Resample draws a new one. Following the chain backward from ∂L/∂a5 = 1, a tanh node multiplies the gradient by its slope tanh′(h), and a × node hands each input the gradient times the other input: ∂L/∂al−1 = wl·∂L/∂hl, and ∂L/∂wl = al−1·∂L/∂hl. Big w pushes h into tanh's flat tails, so the slopes vanish (red tangent lines). Small w keeps every slope near 1, yet the signal shrinks by |w| per layer on the way up and the gradient shrinks by |w| per layer on the way down, and each weight's gradient is scaled by its own tiny input. Red factors in the formula are smaller than 0.1 in magnitude. Click a layer to expand its gradient.