Skip to content
AI.info

Training and optimization

Residual Paths and Deep Network Optimization

Understand residual additions, identity paths, branch scaling, pre-normalization, and why skip connections help optimization without making depth free.

By the end you can

Learning a correction can be easier than rebuilding the signal

A plain block must transform its input into the entire desired output. A residual block can preserve the input and learn only a correction.

The identity route also gives gradients a shorter path through many layers. This can improve trainability, but the residual branch can still dominate, vanish, or waste compute.

The shortcut was published in December 2015, and it bought depth immediately. He and colleagues write that they “evaluate residual nets with a depth of up to 152 layers---8x deeper than VGG nets but still having lower complexity”, and that “An ensemble of these residual nets achieves 3.57% error on the ImageNet test set”. Depth of that order had not been trainable before. The rest of this lesson is about what the shortcut does and does not buy.

Skip connections improve the route through depth; they do not guarantee useful depth.

Visual

An identity path plus a learned branch

Both routes contribute to the next representation. A tensor enters the shortcut and the residual branch together. Layers on the branch compute a learned correction under normalization and activation. A projection or resizing makes the two routes compatible when shapes differ. The addition combines the identity information with the learned change. Later blocks can preserve, refine, or redirect what comes out.

The second route is interesting only because the first is left alone. Keep the skip connection a clean identity, put the activation after the addition, and “the forward and backward signals can be directly propagated from one block to any other block”. That is the claim the same four authors made in their 2016 follow-up on identity mappings. Every design choice below — projection, normalization order, branch scaling — is a choice about how much of that clean route survives.

FigureProcess · 5 steps
  1. 1

    Receive the input

    A tensor enters both the shortcut and residual branch.

  2. 2

    Transform one branch

    Layers compute a learned correction under normalization and activation.

  3. 3

    Align shape if needed

    Projection or resizing makes the two routes compatible.

  4. 4

    Add the routes

    Identity information and learned change form the block output.

  5. 5

    Propagate onward

    Future blocks can preserve, refine, or redirect the representation.

Key idea

Training a deeper model is not evidence that depth was needed

Residual connections can make very deep networks numerically trainable even when extra blocks add no useful capacity for the task. More depth also changes memory, latency, energy, and failure surface.

Compare shallower baselines, ablate block groups, and inspect accuracy versus compute. Trainability is only one condition for a good design. And a deep model that tests worse than a shallow one is not automatically evidence against the depth, as the next section shows.

A stable deep model can still be an inefficient solution.

Case

The same 1202 layers, priced twice, three months apart

He, Zhang, Ren and Sun, who introduced the shortcut, priced unnecessary depth themselves. Its 1202-layer CIFAR-10 network “is able to achieve training error <0.1%”. Its test error was 7.93%, against 6.43% for the 110-layer version. The deeper model, the authors write, “may be unnecessarily large (19.4M) for this small dataset”. Trainable and worth training are two different findings.

That looked like a verdict on depth. It was a verdict on the recipe. In March 2016 Huang and colleagues took the same 1202-layer network and changed only how it was trained. At constant depth the penalty reproduced: their “Training with a 1202-layer ResNet” paragraph records that “the ResNets with constant depth of 1202 layers yields a test error of 6.67%, which is worse than the 110-layer constant depth ResNet”. Then they randomly bypassed blocks during training. Their abstract reports what happened: “With stochastic depth we can increase the depth of residual networks even beyond 1200 layers and still yield meaningful improvements in test error (4.91% on CIFAR-10).”

An independent group logged the same number a year later. Its 2017 table lists ResNet with Stochastic Depth at depth 1202, 10.2M parameters and 4.91 on C10+, next to 110-layer entries at 5.23 and 6.41.

So the same 1202 layers lost to the 110-layer baseline under one training recipe and beat it under another. “Depth did not pay” was a statement about the recipe, not about the depth.

Example

Skip connections do not eliminate these failure modes

Depth remains an engineering choice with measurable costs, and measurable is meant literally. Delete one layer from a trained 15-layer VGG and it collapses. Delete one module from a trained 110-layer residual network and almost nothing happens. Veit and colleagues ran both experiments on CIFAR-10 in 2016: “As expected, deleting any layer in VGG reduces performance to chance levels. Surprisingly, this is not the case for residual networks.” Removing residual modules changed nothing noticeable except at downsampling blocks. Most of the gradient in that 110-layer network came from paths only 10-34 layers deep, and a network trained on those effective paths alone reached 5.96% error against the full model's 6.10%. Six years later three researchers at Google treated the finding as settled: “It is known from prior research (Veit et al., 2016) that residual blocks in a ResNet can be removed without substantially hurting accuracy”. They attribute it to identity skip responses attaining larger values than the residual branches.

  • Branch explosion: Residual outputs grow until additions dominate the identity path and destabilize activation scale.
  • Shape projection: A poorly initialized projection turns the shortcut into another difficult transformation, because a projected shortcut is no longer the clean identity route the block was designed around.
  • Unused depth: Later blocks learn near-zero corrections and consume latency without improving validation behavior — the condition made visible by deleting modules from a trained 110-layer ResNet and seeing no noticeable change in error.
  • Normalization mismatch: A block order copied from another architecture produces unstable or poorly calibrated outputs, and in at least one case does not converge at all.
  • Gradient concentration: Short routes keep gradients alive while selected branches still receive weak task-specific signal; in that 110-layer network the paths carrying most of the gradient were only 10-34 layers deep, out of 110.

Comparison

Pre-normalization, post-normalization and branch scaling change the optimization path

Exact behavior depends on the architecture and on how the block is built. The differences have been measured. The measurements do not all point the same way.

Block order. The pre-activation unit moves normalization and activation inside the residual branch and leaves the shortcut a clean identity. Its authors report what that bought: “We report improved results using a 1001-layer ResNet on CIFAR-10 (4.62% error) and CIFAR-100, and a 200-layer ResNet on ImageNet.” The comparison is against their own 1202-layer post-activation network at 7.93% on the same dataset — nearly twice the error at slightly greater depth. An independent table lists the pre-activation entry too: depth 1001, 10.2M parameters, 4.62 on C10+, with ResNet-110 at 6.61 and 6.41. Post-normalization is not merely riskier at depth. In some architectures it does not train at all. Touvron and colleagues, in 2021: “Note that the original architecture of Vaswani et al. [67] applies the normalization after the block, but in our experiments the DeiT training does not converge with post-normalization.”

Branch scaling. The same paper walks DeiT-S from 12 to 36 blocks and hits a wall: 69.9% top-1, marked training failed, at 64M parameters and 13.8B FLOPs. Adding LayerScale recovers 80.5% at the identical 64M parameters and 13.8B FLOPs. LayerScale is a learnable per-channel diagonal on each residual branch, initialized to 0.1 up to depth 18, 1e-5 at depth 24 and 1e-6 beyond. Nothing about the model changed except the scale on each branch. timm ships it as a standard module, whose LayerScale and LayerScale2d classes default to init_values = 1e-5. Depth alone is not the whole story. In the same paper's Table 1, a 36-block DeiT-S baseline does converge, to 81.9%, once the stochastic-depth drop rate is raised to 0.25. What LayerScale buys is a deep stack that trains without that hand-tuning.

One number per connection is the smaller version of the same idea. Bachlechner and colleagues gate each residual connection with a single parameter initialized to zero, and call it ReZero. Their abstract: “We show that the simplest architecture change of gating each residual connection using a single zero-initialized parameter satisfies initial dynamical isometry and outperforms more complex approaches.” They add: “We apply this technique to language modeling and find that we can easily train 120-layer Transformers. When applied to 12 layer Transformers, it converges 56% faster.”

Two independent evaluations then disagreed about the zero. The same team's Table 1 scores ReZero at 78.3 / 80.1 / 80.8 / 81.6 for depths 12/18/24/36 on ImageNet-1k, against LayerScale's 80.5 / 81.7 / 82.4 / 82.9. The 78.3 at depth 12 sits below the 79.9% DeiT baseline — and their ReZero was an adapted one, with LayerNorm and warmup re-introduced because the original did not converge. Their conclusion: “it is better to initialize alpha to a small value instead of 0, as in LayerScale”. In the DeepNet benchmark, ReZero reaches 26.9 BLEU at 6L-6L on WMT-17 En-De, the weakest entry in the table, and diverges at 18L-18L. Those authors blame instability under half-precision training rather than depth.

That is what checking a scale schedule means in practice. One scheme won on the architecture it was designed for and lost on two others. The only way to know which case you are in is to run the comparison at a matched budget.

FigureComparison · 3 columns

Post-normalization block

Applies normalization after the residual addition or transformation.

  • Historical use: early residual designs
  • Benefit: strong normalization of output
  • Risk: deeper gradient difficulty
  • Check: architecture-specific recipe

Pre-normalization block

Normalizes before the residual transformation.

  • Common use: deep Transformers
  • Benefit: cleaner identity path
  • Risk: output scale can drift
  • Check: final normalization and scaling

Scaled residual block

Multiplies or gates the learned branch before addition.

  • Use: very deep stacks
  • Benefit: controlled early perturbation
  • Risk: branch learns too slowly
  • Check: scale schedule and norms

Visual

Audit a deep residual stack

Use module-level evidence rather than one global curve. Measure branch ratios, comparing residual-branch norm with shortcut and block-output norms. Trace gradients by depth, checking whether early and late blocks receive usable update ratios. Ablate block groups by removing, bypassing or freezing ranges of depth and re-evaluating. Test scaling choices — initialization, gating, residual multipliers — under matched budgets. Then price the benefit: validation gain per unit of memory, latency and training compute.

Step three says groups, not blocks, and two studies explain why. Layers that survive re-initialization one at a time stop surviving it in groups. The Google study that re-initialized the layers of trained networks in 2022 reports both halves: “In summary, the individually robust layers are generally not jointly robust. But with some clever way of picking out a subset of the layers, joint robustness could still be achieved for up to half of the layers.” ResNet-18 was relatively robust. Deeper ResNets were not jointly robust under the same grouping. The graded version of the effect had been measured six years earlier, on a 54-block network: “Performance only drops slightly up to the removal of 10 residual modules, however, for the removal of 20 modules, we observe a severe drop in performance”.

One-block ablations will therefore tell you that almost every block is expendable. Ten of fifty-four are. Twenty are not.

FigureProcess · 5 steps
  1. 1. Measure branch ratios

    Compare residual-branch norm with shortcut and block-output norms.

  2. 2. Trace gradients by depth

    Inspect whether early and late blocks receive usable update ratios.

  3. 3. Ablate block groups

    Remove, bypass, or freeze ranges of depth and re-evaluate.

  4. 4. Test scaling choices

    Compare initialization, gating, or residual multipliers under matched budgets.

  5. 5. Price the benefit

    Report validation gain per memory, latency, and training-compute increase.

Analogy

Editing a document instead of rewriting every page

Nobody retypes a document to change a paragraph. A clean copy is kept and a sequence of tracked edits is applied to it, each editor preserving most content while changing only what is necessary.

Editors can also submit nothing. Blocks do the same. They settle on near-zero corrections that cost latency and change no decision — which is what deleting a residual module from a trained 110-layer network and seeing no noticeable change in error looks like from the outside. So identity preservation and incremental transformation have to be measured block by block, and in groups, rather than assumed from the architecture.

Residual learning asks each block to justify a correction to an existing signal.

Residual paths complement but do not replace other stability tools

Initialization, normalization, learning rate, precision, and optimizer state still determine whether residual branches learn useful corrections. Deep stacks can also suffer representation collapse or oversmoothing in specialized architectures.

The first diagnostic in the previous section has a name and a formula. For a block x+f(x), the block's dependency on its residual branch is Var[f(x)]/Var[x+f(x)]. Liu and colleagues defined it that way in 2020 and priced both ends of the ratio: “heavy dependency on its residual branch makes training unstable, since it amplifies small parameter perturbations (e.g., parameter updates) and results in significant disturbances in the model output. Yet we observe that a light dependency limits the model potential and leads to inferior trained models.” Their numbers say the same thing. On WMT'14 En-De, Post-LN failed outright at 12L-12L and at 18L-18L. Pre-LN converged there, but only to 28.26 and 28.38 BLEU. Their Admin initialization reached 28.58 and 29.03. On WMT'14 En-Fr, Admin stabilized a 72-layer model — 60-layer encoder, 12-layer decoder — to 43.80 BLEU where Post-LN failed and Pre-LN reached 43.10. The DeepNet authors reproduced the shape of that result on WMT-17 En-De: vanilla Post-LN diverged at 18L-18L, Admin held to 28.8 there and diverged at 50L-50L, and vanilla Pre-LN converged at every depth but peaked lower. Stability and ceiling are traded against each other, and the ratio is where the trade is visible.

The lever that moves it can be very small. Xiong and colleagues proved in 2020 that for Pre-LN Transformers “the gradients are well-behaved at initialization”, which “motivates us to remove the warm-up stage for the training of Pre-LN Transformers”, and reported comparable results without it. An entire training stage, deleted by a block reordering. Goyal and colleagues had reached for something smaller still in 2017: “the learnable scaling coefficient γ is initialized to be 1, except for each residual block’s last BN where γ is initialized to be 0”. That one line is shipped code. torchvision's ResNet takes zero_init_residual, and the source comment says why: “Zero-initialize the last BN in each residual branch, so that the residual branch starts with zeros, and each residual block behaves like an identity. This improves the model by 0.2~0.3% according to https://arxiv.org/abs/1706.02677”. Treat the shortcut as one part of a training recipe and validate the complete block behavior.

The identity route is an optimization aid, not a universal architecture verdict.

Key takeaways