Residual Connections
Let each block learn only the correction while the input passes straight through. The identity path is what made 152 layer networks trainable.
Why Does This Exist?
You have a 19 layer network reading scanned receipts and faded characters still misread. The natural move is more depth. A deeper network should manage at least what a shallower one manages, because the extra layers could simply pass their input through unchanged and leave accuracy where it was.
That is not what happened. Past a certain depth, stacked plain layers made training accuracy itself worse. Not held out accuracy, which would point at overfitting. Training accuracy, on data the network had already seen. Researchers building very deep plain networks hit this wall directly, and it has a name: the degradation problem.
The puzzle is sharp. If extra layers can do nothing, the deeper net matches the shallower one. So the extra layers are failing to learn something that sounds trivial, which is to output their input unchanged. This page covers that failure and the one line fix. The surrounding architecture story lives in cnn-architectures, and the stacked operation itself is in convolution-operation. You need only one prerequisite idea here: a layer computes some function of its input, and training adjusts its weights by gradient descent.
Think of It Like This
Grading a correction instead of a rewrite
Ask an editor to reproduce a clean paragraph exactly, word for word, using only a red pen built for marking changes. No copying fresh. Every word must survive untouched through a tool designed to alter text, and one stray mark ruins the copy.
Now give the same editor a simpler instruction: leave the paragraph as it is, and mark only the improvements. Doing nothing is suddenly the easy default. One small fix is nearly as easy. The job shrank from reproduce everything to spot the correction.
A residual block is that second instruction, built into the wiring.
Where it stops: an editor still judges quality, while a residual block never does. The skip path carries numbers faithfully even when those numbers are wrong, so bad labels or exploding scales pass straight through alongside the good signal.
How It Actually Works
A plain block computes some function of its input . Here is the incoming activation vector and is whatever the block layers do, such as a weight multiply followed by a nonlinearity, then another weight multiply. A residual block changes the output to . The input splits. One copy travels the untouched skip path. The other passes through the block layers. The two rejoin by plain addition.
Identity becomes the free default. When every weight inside the block equals zero, and the output is exactly . Small weights give small , so the block starts near do nothing and moves away only as far as training pushes it. The layers no longer reconstruct the whole mapping. They learn only the residual, the correction on top of identity.
Why identity is hard without the skip
A randomly set lands nowhere near the identity function. Reproducing through a matrix multiply and a nonlinearity is one narrow target in a huge space of possible outputs. Gradient descent must find that target separately in every stacked layer, with no help from the structure. Empirically it does not reliably get there, which is why the deeper plain net trains worse.
Gradient keeps a clean path
The forward sum changes the backward flow. Because , the gradient arriving at the block splits into a term that travels back through plus a term of that rides the skip straight to earlier layers. Even where the path through shrinks toward zero, the skip term survives untouched. That is why residuals also soften the vanishing gradient trouble described in vanishing-exploding-gradients. Keep the two benefits apart: degradation is the optimizer failing to find identity, while vanishing gradients are chained small derivatives compounding toward zero. One line of wiring helps both, and batch-normalization still has its own separate job keeping activations well scaled.
Worked example
Take a scalar input and suppose the block layers currently compute . Then . If training has pushed the block weights to zero, and , which is the input reproduced exactly. With a tiny learned correction , the output is . Backward, if the path through carries a gradient of , the total reaching earlier layers is , where the rode the skip.
Code
The check below runs the scalar case from the worked example with only the standard library. It confirms the identity default and the small correction behavior directly.
def residual_block(x: float, f: float) -> float: return f + x
x = 2.0print(residual_block(x, 0.5)) # -> 2.5print(residual_block(x, 0.0)) # -> 2.0print(residual_block(x, 0.02)) # -> 2.02Zero inside gives the input back exactly. A small inside value gives a small nudge away from the input, which is the whole point: the block starts at do nothing and learns a correction from there.
Watch Out For
Addition fails when shapes change
The symptom is a shape error at the sum. The block preserved spatial size and channel count everywhere else, then one stage doubled the channels and the bare no longer lines up.
Use a projection shortcut on the skip path only where the shape changes: a small one by one convolution that reshapes to match before the addition. It is a trained reshape, not a free identity, and it belongs only at those transition points.
Expecting the skip to replace normalization
The symptom is a very deep residual net that still will not converge once normalization layers are removed. Training wobbles or stalls, and the skip path gets the blame.
The skip makes identity easy while normalization keeps each layer input in a workable range. They solve adjacent problems, and modern deep nets use both. If you remove normalization, put it back before doubting the skip.
The Quick Version
- Stacking plain layers past a certain depth makes training accuracy itself worse, which is the degradation problem rather than overfitting.
- A residual block outputs , so zero block weights give the input back exactly.
- The layers inside learn only the correction on top of identity, a far smaller target than the full mapping.
- The skip gives gradients a path that bypasses , which also softens vanishing gradients without replacing normalization.
- Shape changes need a projection shortcut on the skip path at that stage only.