Skip to content
AI360XpertBeta
Core ML

Visual explainer

Residual Connections

Follow an input through identity and residual routes, add their gradients, match tensor shapes and see why shortcuts do not guarantee stable signals.

An extra plain layer can disturb an existing prediction.
An extra plain layer can disturb an existing prediction.

Residual connections add a learned correction to an unchanged input: H(x)=x+F(x)H(x)=x+F(x). This makes identity available by setting the residual function to zero. It can ease optimization, while still leaving the network's total behavior dependent on the branch.

The picture is a synthetic starting problem, not a training benchmark: an existing prediction 2 matches target 2, but appending a plain layer that multiplies by .5 changes it to 1. Extra capacity alone does not preserve an already useful mapping. The original Deep Residual Learning paper reports degradation in deeper plain networks' training error and motivates learning residual mappings. This toy arithmetic illustrates the identity-preservation issue without claiming those scalar values reproduce the experiments.

Add A Correction

A residual branch adds its correction to the unchanged input.
A residual branch adds its correction to the unchanged input.

Follow input x=2x=2 along both routes. The identity route carries 2 unchanged; the illustrative branch F(x)=.25xF(x)=.25x computes .5. Addition produces H(2)=2.5H(2)=2.5. The dot marks a real fork, and the upper route visibly bypasses the branch. In a tensor block, addition happens element by element at matching spatial positions and channels. These scalar values teach the mechanism rather than a trained model's performance.

Add Gradient Contributions

The input gradient includes both identity and branch contributions.
The input gradient includes both identity and branch contributions.

With incoming loss sensitivity 1, the identity derivative contributes 1 and this branch contributes .25. The arrows use one signed-sensitivity scale: the .25 segment is one quarter of the unit segment, and the combined displacement is 1.25. Vertical offsets separate the head-to-tail pieces without changing their lengths.

For this scalar block, dL/dx=(dL/dH)(1+F′(x))dL/dx=(dL/dH)(1+F'(x)). For vectors, the corresponding Jacobian is I+JFI+J_F, and backward propagation applies its transpose. The identity term provides a direct contribution; it does not set the total gradient to one.

Match The Shapes

A projection makes shortcut and branch shapes match.
A projection makes shortcut and branch shapes match.

Change from scalar values to a small shape example. The input has height 4, width 4 and one channel. A 1×11\times1 projection convolution with stride 2, no padding and two output channels produces 2×2×22\times2\times2. Each plane's grid shows spatial cells; the two offset planes represent channels, not measured activation values. The residual branch supplies the same output shape before element-wise addition.

The spatial size is ⌊(4−1)/2⌋+1=2\lfloor(4-1)/2\rfloor+1=2. The two output channels are learned linear combinations of the input channels at sampled positions. A projection adds parameters and computation and changes the shortcut derivative from identity to the projection operator. Equal shapes make addition possible; they do not make the shortcut an identity mapping.

Compare Derivative Products

Residual and plain scalar blocks have different derivative products.
Residual and plain scalar blocks have different derivative products.

Compare ten plain maps x↦.25xx\mapsto.25x with ten residual blocks x↦x+.25xx\mapsto x+.25x. Starting from unit terminal sensitivity, the plain product is .2510=0.0000009536743.25^{10}=0.0000009536743, while the residual product is 1.2510=9.31322571.25^{10}=9.3132257. The plot shares a logarithmic vertical scale; horizontal ticks count backward blocks. The dashed plain route shrinks, while the solid residual route grows.

This is a controlled scalar construction. It shows a direct term can change the product substantially, and also disproves the claim that a residual network's total gradient must remain near one. Real branch Jacobians vary with parameters and inputs; skip connections provide a structural advantage without a universal gradient ratio.

Move Activation Inside The Branch

A post-addition ReLU changes the identity mapping for negative inputs.
A post-addition ReLU changes the identity mapping for negative inputs.

Set F=0F=0 to isolate activation placement. A clean addition output gives H(x)=xH(x)=x, shown by the solid line. Putting ReLU after addition instead gives H(x)=max⁡(0,x)H(x)=\max(0,x), shown dashed. At input −2, the clean output is −2 (circle), whereas the post-ReLU output is zero (square). The positive branches coincide intentionally. Both curves share input and output scales.

Identity Mappings in Deep Residual Networks moves normalization and activation into the residual branch to preserve a direct identity route across additions. Removing a post-addition gate preserves that route; the branch can still amplify or cancel the total signal. A clean route is not a guarantee about the complete function.

Addition Can Amplify Signals

Repeated residual additions can amplify activations.
Repeated residual additions can amplify activations.

For a different branch, F(x)=xF(x)=x, each block computes H(x)=2xH(x)=2x. Starting at 1, three blocks yield 2, 4 and 8. The bars use one linear scale, with the final cross marking unchecked amplification. The value 8 is finite; the picture is a counterexample to automatic stability, not a numerical-overflow threshold. Activation variance depends on branch statistics and covariances, so this deterministic example makes no universal variance-growth claim.

Represent Identity With Zero

A zero residual represents an identity block.
A zero residual represents an identity block.

Return to F(x)=0F(x)=0 over the plotted domain. The dashed branch remains zero; the solid block output is H(x)=xH(x)=x. At input 2, branch output is zero while block output is 2. This is the representational convenience of the residual formulation: the branch can represent no correction rather than synthesizing the full identity transformation internally.

That statement is conditional on a zero residual function and no post-addition operation that alters it. Weight decay does not guarantee that a trained branch becomes exactly zero: biases, normalization parameters, architecture and optimization all matter. An input-dependent zero at one point also does not imply a zero derivative there.

Scale The Correction

Residual scaling changes the size of each additive correction.
Residual scaling changes the size of each additive correction.

With F(x)=xF(x)=x and input 2, use H(x)=x+αF(x)H(x)=x+\alpha F(x). At α=1\alpha=1, the correction is 2 and output is 4. At the illustrative α=.1\alpha=.1, the correction is .2 and output is 2.2. The arrows share one value scale, making the tenfold difference in correction length literal. Closely spaced endpoint labels are displaced slightly for legibility; dashed guides identify their exact positions.

The derivative becomes 1+αF′1+\alpha F'. Scaling can moderate each branch's contribution, but .1 is not a universal prescription. Even repeated factors of 1.1 can grow: three such scalar blocks amplify by 1.13=1.3311.1^3=1.331. Choose architecture and initialization for the actual network rather than assuming a fixed scale guarantees stability.

Where It Breaks

A branch equal to negative input collapses the residual block to zero.
A branch equal to negative input collapses the residual block to zero.

Finally choose F(x)=−xF(x)=-x. Inputs −2, 0 and 2 all map to zero under H(x)=x+F(x)H(x)=x+F(x); the amber horizontal line has slope zero. The dashed diagonal is the identity reference that the branch cancels. Here the derivative is 1+(−1)=01+(-1)=0, so this block passes no input sensitivity backward despite its identity wire. This local mechanism is an explicit limit, not a claim that residual networks usually learn cancellation. Skips help make deep optimization practical; they cannot guarantee useful representations, stable magnitudes or generalization.

The Quick Version

  • Residual blocks add a correction to a shortcut input.
  • Identity and branch derivatives both contribute to the total.
  • Projection shortcuts match shapes at an additional computational cost.
  • Post-addition activations can alter the identity route.
  • Zero residual functions can represent identity blocks.
  • Residual additions can amplify signals or cancel gradients.