How does the product of layer Jacobians explain vanishing and exploding gradients in a deep feed-forward network, and why are sigmoid networks especially prone to vanishing gradients?

Deep learning, Optimisation of deep networks
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can write the backward pass as a product of Jacobians and bound its norm.

Key idea

Let layer l compute zl=Wlhl−1 and hl=ϕ(zl), with activation ϕ. Its Jacobian (the matrix of partial derivatives) is Jl=diag⁡(ϕ′(zl)) Wl, and ∂hL∂h0=JLJL−1⋯J1. Using the spectral norm ∥⋅∥ (the largest singular value), ∥∂hL∂h0∥≤∏l=1L∥diag⁡(ϕ′(zl))∥ ∥Wl∥. A product of L factors shrinks or grows geometrically.

Steps

  1. Write the layer map and its Jacobian: Jl=∂hl∂hl−1=diag⁡(ϕ′(zl)) Wl.
  2. Apply the chain rule, writing L for the loss: ∂L∂h0=(JL⋯J1)⊤∂L∂hL.
  3. Bound the norm by the product of the factor norms. If each factor is below 1, the gradient vanishes geometrically in L. If the largest singular values are consistently above 1, it explodes.
  4. Sigmoid: σ′(z)=σ(z)(1−σ(z))≤14. With ∥Wl∥≈1 the bound is (1/4)L; for L=10 that is about 10−6. So the early layers barely learn.
  5. List remedies and what each fixes: ReLU (ϕ′∈{0,1}, so no shrinking factor); Xavier or He initialisation, to keep the factors near 1; batch or layer normalisation; residual connections (J=I+∂F/∂h, where F is the residual branch, so the identity carries the gradient); and gradient clipping for exploding gradients.

Common mistakes

How long your answer should be

About 3 minutes; one product formula and one bound.

Last checked on 4 December 2026.

Read this

Previous in Deep learning: For a two-layer network h=ReLU⁡(W1x+b1), y^=softmax⁡(W2h+b2), trained with cross-entropy on one example with true class c, what are the gradients of the loss with respect to W1,b1,W2,b2 in matrix form, and do their shapes check out?
Next in Deep learning: What is the batch normalisation forward pass for one feature? For a mini-batch of activations [1,2,3,6] with γ=2, β=1 and ϵ≈0, what are the outputs? What changes at inference time, and why do transformers use layer normalisation instead?