Home/How Learning Works

Residual and Skip Connections

Chain enough shrinking layers and the gradient reaching the first one is indistinguishable from zero. A skip connection adds a path the gradient cannot shrink along.

The Stack

10

every layer squashes its input by the same factor (local derivative 0.55) — realistic for a deep sigmoid/tanh stack

Gradient Magnitude, Layer By Layer

At The Input Layer

Gradient Magnitude
0.0025
Per-layer factor0.55

 

Residual Connections: A Practical Guide

A shortcut for the gradient, not just for the signal.

Quick Context

Stack enough layers and, by the chain rule, the gradient reaching an early layer is the product of every local derivative between it and the loss. If each of those derivatives is reliably less than 1 — true of sigmoid and tanh almost everywhere — the product shrinks geometrically. Ten layers at a local derivative of 0.55 already leaves the input gradient at about 0.0025 of what it started as; twenty leaves it at six millionths. That is the vanishing gradient, and it is why very deep plain networks were nearly untrainable before residual connections.

What a skip connection changes

plain:   xi+1 = f(xi)   →   dxi+1/dxi = f'(xi)

residual: xi+1 = xi + f(xi)   →   dxi+1/dxi = 1 + f'(xi)

Adding the input back on gives the local derivative a constant +1 term. Whatever f' does — shrink toward zero, even go slightly negative — the identity path contributes exactly 1 at every layer, so the product across the whole stack can no longer collapse toward zero the way a chain of pure f' terms does. The gradient always has at least the unimpeded identity route back to the input.

Interactive Exploration Guide

  1. Read the plain stack at 10 layers. The gradient at the input is 0.5510 ≈ 0.0025 — over 99% of it is gone before it reaches the first layer.
  2. Turn on skip connections. The same ten layers, the same 0.55 local derivative, and the input gradient jumps to 1.5510 ≈ 80 — nowhere near zero.
  3. Push the layer count to 16. Without skips, the bars nearest the input are visually gone — the y-axis is logarithmic and they are still off the bottom. With skips, every bar stays a real, usable number.
  4. Note what does not change. The per-layer factor is identical in both cases — 0.55, the same squashing. Nothing about the layers themselves improved; only the path the gradient can take did.

Key Takeaway

A residual connection adds the block's input back onto its output, which adds a constant 1 to that layer's local derivative during backpropagation. A chain of derivatives all below 1 shrinks geometrically and vanishes; a chain that includes a guaranteed +1 at every step cannot collapse toward zero regardless of how small the learned part's derivative is. This is why residual connections, not just wider layers or better optimisers, were the change that made networks with over a hundred layers trainable at all.

Predict, then reveal

About to run: Turn on skip connections. Before it does — what happens to the readout?

Committing to an answer first is the point — the reveal runs the experiment on the visualisation above and reads the real value back, so nothing here is scripted.

Recall check

0 of 3

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. Without scrolling back — what is the one-line takeaway from this module?

  2. What does this module say about “The Stack”?

  3. What does this module say about “Quick Context”?

Cheat sheet

Residual and Skip Connections

Chain enough shrinking layers and the gradient reaching the first one is indistinguishable from zero. A skip connection adds a path the gradient cannot shrink along.

DEEP LEARNING · vizlearn.in/deep_learning/residual_connections.html