Answers · The mathematics underneath
Why does adding a shortcut connection stop gradients from vanishing?
In shortA shortcut gives the gradient a route whose factor is one plus the layer's own factor, so many layers in series no longer multiply the signal down to nothing.
The gradient reaching an early layer is a product with one local factor for every layer between it and the loss. A shortcut connection adds the layer's input to what the layer computes, so each factor becomes one plus the layer's own factor, and the product now contains an identity route whose factor is exactly one at every depth.
Take a plain stack in which every layer contributes the same factor. With a factor of 0.9, the derivative after fifty layers is of what entered at the loss; with a factor of 1.1 it is . Neither factor is far from one, yet the two outcomes are not close: the first has shrunk to about five thousandths, the second has grown to about a hundred and seventeen. The product is exponential in the number of layers, so an average factor a tenth below one is already catastrophic at depth fifty, and an average factor a tenth above one is already unstable.
Saturating functions make the small case systematic rather than unlucky. A squashing unit flattens for large inputs, and a flat unit has a derivative near zero. Take a saturated unit whose local factor is 0.01: the forward value looks confident and settled, while the derivative that would move it has almost closed. Put fifty such units in series and the product is , which is . Nothing overflows and nothing raises an error; the early layers simply receive no usable signal while the late layers train normally.
Now change one layer so that it computes instead of . The derivative of the output with respect to the input is no longer alone: the direct path contributes one. Writing , the local factor is . If the computed branch has collapsed and , the factor is exactly one. If it is saturated at , the factor is 1.01.
Repeat that saturated factor fifty times. Without the shortcut the product is . With the shortcut round each unit it is , and . The computed branches still contribute their 0.01, but the one from the shortcut is present in every factor, so the small contributions are no longer the only thing multiplying the signal.
What the shortcut is not
The natural guess is that a shortcut is an accuracy trick: it gives the network an easier function to fit, or it carries information forward, and the gradient improvement is a side effect of better representations. The gradient effect is earlier than that. It is a change in the local factor itself, from to . The identity path is not only a forward-pass copy of the input. It is a term in the derivative that is one at every depth, so even when every computed branch is saturated and contributes almost nothing, the product has a route that contains none of those small factors.
The leading one on the right is the identity route. If every the whole product is one and the arriving derivative is , not zero. The other terms still contain the small factors, and they can be tiny, but they no longer multiply the entire signal. That is why the fix is described as adding a one: it changes the product rather than the representation.
Where the argument stops
The one is not unconditional. If is close to , then is close to zero, and a long stack of such factors can still vanish; if is large positive, the product can explode. A shortcut with a learned scaling or a projection has factor rather than , and a small can put the shrinkage back. What the shortcut removes is the forced collapse of a long chain of small positive factors, not every possible bad product. Normalisation and careful initialisation keep near zero so the factors sit near one, and clipping caps the product after it has grown too large. Those act at different points: the shortcut changes the factor, normalisation changes the inputs that produce it, initialisation changes the starting weights, and clipping changes the final number.
Worth keeping
- With one local factor per layer, the derivative reaching an early layer is a product whose size is exponential in depth.
- A shortcut makes each local factor one plus the layer's own factor, so the product contains an identity route that does not shrink.
- A factor close to minus one or a large positive factor can still make the product vanish or explode, so the shortcut is not an unconditional guarantee.
Where this goes next
This question is one step of Backpropagation in Full, a course that works through its subject from the beginning. The page that teaches this part of it is Why the Signal Fades or Explodes, and it reads the whole way through whether or not you have an account.
What an account changes is the practice: problems standing under every idea, marked with a reason rather than a tick, in a copy of the course that is yours.
Read that pageThe whole courseOther questions people ask about this
- Why does backpropagation never build the full Jacobian?Backpropagation only needs a vector multiplied by each layer's derivative matrix, so it computes that product directly and never builds the matrix.
- Why does softmax followed by cross entropy have gradient p minus y?Because the derivative of the loss through softmax simplifies to the predicted probability minus the target, one number per class, with the exponentials and fractions cancelling out.
- Why do derivatives multiply along a chain but add when the path splits?Along a chain each step scales the effect that arrived, so the scalings multiply; at a split each use contributes its own effect to the same change, so the contributions add.
- What does a computation graph actually let you differentiate?It lets you differentiate a final number with respect to any earlier value in the graph by multiplying local derivatives along each route and adding across routes.
- What is the difference between variance and standard deviation?They measure the same spread: variance is the average squared distance from the mean, standard deviation is its square root, so you report the standard deviation and calculate with the variance.
- How do you make a vague claim precise enough to tell whether it's true?Fix what is being talked about, what is asserted, which cases are covered and the cut-off, then name an observation that would prove it false.