The vanishing gradient problem occurs when gradients become progressively smaller as they propagate backward through a deep neural network. Early layers then receive weak weight updates, making them difficult to train. Shortcut, skip, or residual connections create shorter gradient paths by adding an earlier layer’s output to a later layer’s output. section 4.4
Figure 4.12 A comparison between a deep neural network consisting of five layers without (left) and with shortcut connections (right). Shortcut connections involve adding the inputs of a layer to its outputs, effectively creating an alternate path that bypasses certain layers. The gradients denote the mean absolute gradient at each layer, which we compute in listing 4.5.
Compare five-layer networks with and without shortcut connections; the figure traces mean absolute gradients across layers. section 4.4
A small PyTorch experiment makes the training effect measurable:
- Build five Linear–GELU layers with three-value intermediate representations and a one-value output. section 4.4
- Compute mean absolute weight gradients after applying MSE loss and calling loss.backward(). section 4.4
- Compare models without and with shortcuts: the reported gradients rise from roughly 0.0001–0.0050 to 0.207–1.326. section 4.4













