What a residual network is
More layers should never make a network worse: the extra layers could learn to pass their input through unchanged. Yet He et al. found that a plain 56-layer network had a higher training error on CIFAR-10 than a 20-layer one, so the optimiser was failing to find even that solution. A residual network builds it in. Each block computes a correction and adds it to its own input,
so a block that should do nothing only has to push towards zero. The page runs the released ResNet-50 (microsoft/resnet-50, 25.6 M parameters, 1,000 ImageNet classes) on one 224 × 224 photo of a beagle; the network's top class is beagle, with probability 0.992.
Stem, four stages and the head
A 7 × 7 convolution with stride 2 (the stem, 64 learned kernels) and a 3 × 3 max pool with stride 2 take the photo from 224 × 224 to 56 × 56. Four stages of 3, 4, 6 and 3 bottleneck blocks follow. The first block of stages 2 to 4 halves the grid with a stride of 2, so it shrinks 56 → 28 → 14 → 7 while the channels widen to 256, 512, 1,024 and 2,048. The 16 blocks hold 48 convolutions; with the stem and the classifier they are the 50 layers of the name. This checkpoint puts each stage's stride on the 3 × 3 convolution rather than the first 1 × 1, the variant torchvision calls v1.5 (ResNet-B in Tong He et al.'s Bag of Tricks): a 1 × 1 convolution with stride 2 would skip three quarters of its input.
After stage 4 each of the 2,048 channels is averaged over its 7 × 7 grid, and one linear layer maps the 2,048 means to 1,000 logits. The What voted for panel splits the top logit into its 2,048 terms, weight times pooled value: the beagle logit, 3.678, is the bias −3.544 plus the sum of the votes, and the panel shows where on the grid the eight largest voters fired.
The bottleneck block
Each block narrows the channels with a 1 × 1 convolution, mixes neighbouring pixels with a 3 × 3 convolution at the narrow width, and widens back with another 1 × 1: in stage 1, 256 → 64 → 64 → 256. Each convolution is followed by batch normalisation, and all but the last by a ReLU. Batch normalisation standardises each channel with statistics gathered during training, then rescales it with two learned numbers per channel,
which at inference time is a fixed affine map. Where a block changes the shape (the first block of each stage) the shortcut is a 1 × 1 convolution with batch norm instead of the identity. The block panel draws four channels of each step and the RMS over all of them; on this photo the final ReLU zeroes between 33 % and 93 % of + shortcut, the most in stage 4.
How much each block adds
The How much each block adds chart plots for all 16 blocks. Through stages 1 and 2 the correction is about as large as what it is added to (0.93 to 1.09). In stage 3 it is 1.3 to 2.1 times as large, and in stage 4 the first block's is 0.92 and the last two blocks' 4.1 and 3.5. No block comes close to doing nothing on this photo; each output is its input plus a change of the same order or larger.
The gradient through the skip
The addition also shapes the backward pass. Let be the gradient at the sum, after the final ReLU's mask. It goes back to the block's input two ways at once, straight through the identity and through :
Stacking blocks multiplies such sums, so the gradient that reaches an early layer contains a path that crosses no convolution at all, beside paths through one, two or more of the 48. The gradient flowing back chart follows the gradient of the beagle logit through every block on a log scale, split into the part sent back through the skip and the part through . The two parts add up exactly to the gradient at , and their cosine on this photo stays between −0.001 and 0.17: the branch adds a nearly orthogonal component rather than cancelling the skip.
He et al.'s second paper kept the identity path completely clean by moving batch norm and the ReLU inside (pre-activation blocks). Veit, Wilber and Belongie showed that a trained ResNet behaves like an ensemble of many paths of different lengths, and that during training most of the gradient comes from the short ones.
Receptive field
Each 3 × 3 convolution widens what a unit can see by twice the spacing (the jump) between its input units, and each stride doubles the jump. After stage 3 the jump is 16 pixels and a unit's theoretical receptive field is 267 pixels, more than the 224-pixel photo; after stage 4 it is 427. The Receptive field panel draws the real gradient of the centre unit with respect to the input pixels: after stage 3, 97 % of it comes from the middle half of that window. The 16-pixel step of stage 3's 14 × 14 grid matches a ViT's 16 × 16 patches, but a ViT token can attend to any patch from the first layer, while a ResNet unit widens its view only layer by layer.
Where it came from
Highway networks (Srivastava, Greff and Schmidhuber, 2015) had already trained very deep networks with gated shortcuts, a learned mix of and . ResNet's ungated identity was simpler and went further: He et al. trained a 152-layer network on ImageNet and networks of over 1,000 layers on CIFAR-10, and won the ILSVRC 2015 classification task. Batch normalisation, published the same year, is what lets each train at a sensible scale. The residual connection outlived the convolutions: every transformer block adds its attention and its MLP to a residual stream, , exactly as a ResNet block does, and the ViT applies that block to image patches.
Papers
- Deep Residual Learning for Image Recognition Residual blocks, the degradation problem they solve, bottleneck blocks and ResNet-50, the network this tab records.
- Identity Mappings in Deep Residual Networks Why a clean identity path lets the signal and the gradient pass between any two blocks; pre-activation blocks.
- Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift Batch normalisation, which follows every convolution in ResNet.
- Highway Networks Gated shortcuts that made very deep networks trainable months before ResNet.
- Residual Networks Behave Like Ensembles of Relatively Shallow Networks Reads a ResNet as many paths of different lengths and finds the short ones carry most of the gradient.
- Bag of Tricks for Image Classification with Convolutional Neural Networks Names the ResNet variants; ResNet-B moves the stride to the 3 × 3 convolution, as this checkpoint does.
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale The Vision Transformer, which replaced convolutions with attention over 16 × 16 patches but kept the residual connections.