The Deep Learning Death-Spiral: Gradient Vanishing and Exploding
Why deep networks used to 'die' during training before ResNets and Batch Norm.
In the early 2000s, training a neural network with more than 10 layers was considered a "Dark Art." It wasn't because we didn't have the data—it was because the networks would simply "die" during training.
This was the problem of Vanishing and Exploding Gradients.
The Math: The Chain Rule Multiplier
To train a neural network, we use the chain rule to propagate the "error" from the output back to the weights.
Think of it like a game of "Telephone." Each layer of the network multiplies the gradient by its own weights.
- The Exploding Gradient: If the weights are slightly greater than 1.0, and you multiply them 50 times, the gradient becomes Infinitely Large. The model's weights "explode" to NaN (Not a Number) and the network crashes.
- The Vanishing Gradient: If the weights (or the activation function derivative) are slightly less than 1.0, and you multiply them 50 times, the gradient becomes Zero. The weights at the beginning of the network never change, and the model never "learns" anything.
The Breakthroughs: ResNets and Normalization
Two inventions saved Deep Learning:
- Batch Normalization: This "rescales" the outputs of every layer during training, ensuring they stay in a "safe" range (around 0 and 1).
- Residual Connections (ResNets): This was the real game-changer. ResNets added "Skip Connections" that allow the gradient to "bypass" the layers and flow directly back to the beginning of the network.
Why It Matters Today
Every model you use—from GPT-4 to Midjourney—is built on these foundations. Without ResNets and Normalization, the "Deep" in "Deep Learning" would have never happened. We would have been stuck with shallow, 3-layer networks forever.