Explaining vanishing gradients and solutions
Sigmoid and tanh saturate for large inputs, making their derivatives near zero, so multiplying these small derivatives across many layers causes gradients to vanish. Sigmoid’s derivative maxes at 0.25; tanh’s max is 1 at zero but usually less elsewhere. ReLU avoids this by having derivative 1 for positive inputs, preserving gradient magnitude and preventing shrinkage in active neurons. Residual connections add identity skip paths allowing gradients to flow directly, bypassing saturating nonlinearities and reducing effective depth, which together alleviate vanishing gradients.
Back–propagation is just repeated application of the chain rule. The gradient of a loss (L) with respect to a weight in layer (k) contains a factor for every downstream layer
[
\frac{\partial L}{\partial w_k} = \frac{\partial L}{\partial a_{n}};\frac{\partial a_n}{\partial a_{n-1}};\frac{\partial a_{n-1}}{\partial a_{n-2}};\cdots\frac{\partial a_{k+1}}{\partial a_k};\frac{\partial a_k}{\partial w_k},
]
where (\partial a_{i}/\partial a_{i-1}) involves the derivative of whatever nonlinearity you chose. For sigmoid (\sigma(x) = 1/(1+e^{-x})) the derivative is (\sigma(x)(1-\sigma(x))), which is at most 0.25 and tends to 0 as (x) goes to (\pm\infty). For (\tanh) the derivative (1-\tanh^2(x)) has a similar shape: it's 1 at the origin, but it very quickly drops to zero as (|x|) grows. In a deep network most units will not sit exactly at 0, so you end up multiplying a long chain of numbers smaller than one. The product decays exponentially with depth, which is what people refer to as the vanishing gradient problem.
Two of the design changes that mitigate this are:
- Use a non‑saturating activation such as the rectified linear unit, (\mathrm{ReLU}(x)=\max(0,x)). For (x>0) its derivative is exactly 1, so along active paths the chain of derivatives is a chain of ones rather than a chain of quarters. There is no compression of the positive signal into a small interval, so the positive side does not saturate.
- Add skip/identity connections as in residual networks. A residual block computes (y = F(x)+x). In back‑propagation, (\partial y/\partial x = \partial F/\partial x + I). Even if (\partial F/\partial x) has small entries because of nonlinearities, the identity term provides a direct path for the gradient with derivative 1. This bypass reduces the effective depth that the gradient has to traverse and prevents it from being extinguished by repeated multiplication by small slopes.
Combined with appropriate initialization and normalisation, these choices greatly reduce the tendency of gradients to vanish in deep models.