Why can gradients vanish or explode in deep networks, and how do Xavier/He initialisation, residual connections and normalisation address this?
Answer
Model answer, written in a candidate's voice
In short
- Backprop multiplies many layer Jacobians, so gradients shrink or grow geometrically with depth.
- Variance-preserving init: Glorot/Xavier uses 2/(fan_in+fan_out); He uses 2/fan_in for ReLU-like activations.
- Residual connections add an identity path, so gradients can flow through y=x+F(x).
- Normalisation layers stabilise activation/gradient scale; gradient clipping caps exploding gradients.
- Historical note: LSTM gating used additive cell-state paths to reduce vanishing gradients in recurrent networks.
In full
Gradients vanish or explode because backpropagation multiplies many layer Jacobians, so if each factor is slightly below or above 1, the product decays or grows geometrically with depth. Variance-preserving initialisation keeps forward activations and backward gradients at a stable scale: Glorot/Xavier uses variance 2/(fan_in+fan_out), while He initialisation uses 2/fan_in for ReLU-like activations because ReLU roughly halves the signal variance. Residual connections help by giving gradients an identity path: for y=x+F(x), the Jacobian contains I plus the Jacobian of F, so information can flow even when F is hard to train. Normalisation layers such as batch or layer normalisation keep activation scales from drifting across layers, and gradient clipping is used to prevent exploding gradients from destabilising training, though it does not by itself fix vanishing gradients. Historically, LSTM gating used additive cell-state paths and learned gates to keep gradients from vanishing in recurrent networks, an idea that later influenced residual architectures.
What a strong answer covers
- Products of many layer Jacobians shrink or grow geometrically.
- Variance-preserving initialisation: He uses 2/fan_in for ReLU; Glorot uses 2/(fan_in + fan_out).
- Residual connections give identity paths for gradients.
- Normalisation layers, and gradient clipping against explosions.
- Historical note: LSTM gating.
Common mistakes
- Claiming ReLU alone solves vanishing gradients.
- Mixing up fan-in and fan-out.