Residual Learning
Layers learn the change to make to their input rather than the whole output.
The idea
Instead of asking a block to learn H(x) directly, ask it to learn the residual F(x) = H(x) − x and output x + F(x). If the best thing to do is nothing, the block only has to push F toward zero, which is easy. The identity shortcut also lets gradients flow directly to early layers.
y = F(x, {W}) + x
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- plain
- with skip connections
The learning signal (gradient) starts at the output and travels backwards through 20 layers. Bar height shows its size at each layer on a log scale.
- layers back:
- 0
A residual block computes x + F(x). The "+ x" is a shortcut the gradient can travel along.
Step by step
- 1Pass the input through a few layers to get F(x).
- 2Add the original input back: y = x + F(x).
- 3Apply the activation.
- 4Stack many such blocks.
Where it is used
ResNets, transformers, and almost every deep architecture.
Watch out for
Shapes must match for the addition, otherwise a projection is needed.