Skip to content
mlmentorship

ResNet

Residual connections enabled networks deeper than 30 layers to train. Still the dominant backbone for transfer learning in 2026.

Published · 6 min read ·Specialist ·Intermediate

Visual quick review

Visual first · depth when needed

Decide when a ResNet shortcut can remain an identity and when it must project the input so both branches have the same shape before addition.

Preparing the visual…

Summary

ResNet (He et al., 2015) introduced residual connections. Adding the input of a block to its output, so each block computes rather than . This solved the degradation problem of very deep networks and enabled the first widely-trainable 50–152 layer CNNs.

Before ResNet, networks past ~20 layers showed worse training accuracy than shallower ones. Not from overfitting but from optimization difficulty. ResNet (2015) tied SoTA on ImageNet with 152 layers and won the competition. The residual idea is now ubiquitous: every transformer, every modern CNN, every U-Net.

ResNet-50 remains the default transfer-learning backbone in 2026. Pretrained checkpoints widely available, well-understood behavior, fast inference.

The residual block

The building block of ResNet:

input x

Conv 3x3 → BN → ReLU

Conv 3x3 → BN

+ x   (identity skip)

ReLU

That + x is the residual connection. If the spatial / channel dimensions change, is projected through a conv first.

Bottleneck block (ResNet-50/101/152)

To make very deep networks compute-efficient:

input x

Conv 1x1 → BN → ReLU   (reduce channels: 256 → 64)

Conv 3x3 → BN → ReLU   (compute at low channel count)

Conv 1x1 → BN          (expand channels: 64 → 256)

+ x

ReLU

The bottleneck keeps the expensive convolution at one-quarter of the block’s output channel width. The two cheap convolutions reduce and then restore the channels, avoiding spatial convolution at the full width.

Learning objective: decide when a ResNet shortcut can remain an identity and when it must project the input so both branches have the same shape before addition.

The addition contract

A shortcut is free only while the block preserves tensor shape.

Identity and projection shortcuts in ResNet bottleneck blocks The top panel shows a within-stage bottleneck. An input tensor of shape 56 by 56 by 256 travels through a main branch that narrows to 64 channels and restores 256 channels. The unchanged identity shortcut and main output both have shape 56 by 56 by 256, so they can be added. The lower panel shows a stage-transition bottleneck. The main branch downsamples and expands to 28 by 28 by 512. A crossed-out raw identity remains 56 by 56 by 256 and cannot be added. A one-by-one stride-two projection converts the shortcut to 28 by 28 by 512, matching the main branch for valid element-wise addition. WITHIN A STAGE: IDENTITY SHORTCUT input x 56×56×256 bottleneck F(x) 64-channel middle output 56×56×256 + valid identity: x stays 56×56×256 NEW STAGE: PROJECTED SHORTCUT input x 56×56×256 bottleneck F(x) stride 2 downsamples output 28×28×512 + valid raw x is still 56×56×256 1×1 projection, stride 2 output 28×28×512
Read it this way: compare shapes at the plus sign. Inside a stage, the bottleneck restores 56×56×256, so unchanged x is already compatible and the shortcut has no weights. At a new stage, the main branch produces 28×28×512; raw x cannot be added element by element, so a 1×1 stride-2 convolution projects the shortcut to the same shape. Original schematic checked against He et al. (2015) and the TorchVision ResNet documentation.

Why residuals work

Three intertwined explanations:

  1. Easier to learn the identity. If a layer’s optimal contribution is “do nothing,” it’s easier to drive than to learn the identity through a stack of conv + BN + ReLU.
  2. Gradient highway. Backprop through has Jacobian . The identity term provides a direct additive gradient path, improving optimization across depth.
  3. Implicit ensemble (Veit et al., 2016): a depth- ResNet behaves like an ensemble of paths of varying depth. Shallow paths learn quickly and provide signal; deep paths refine.

See residual connections for the more detailed gradient analysis.

ResNet variants

VariantDepthBlock typeNotes
ResNet-18, ResNet-3418, 34Basic ( + )Smaller models
ResNet-5050BottleneckMost common; 25M params
ResNet-101, ResNet-152101, 152BottleneckHigher accuracy; slower
ResNeXtvariesGrouped conv bottleneckMore parallelism within blocks
Wide ResNet16-50Basic, wider channelsDepth-vs-width tradeoff

Pre-activation ResNet

He et al. (2016) revisited the block ordering and proposed pre-activation:

x → BN → ReLU → Conv → BN → ReLU → Conv → + x

Normalization and activation come before the conv. Cleaner identity mapping, slightly better training. Used in some later models; classic ResNet-50 is post-activation.

The same pre/post norm question recurs in transformers (see residual connections).

ResNet’s legacy in 2026

Despite ViT and ConvNeXt being SoTA on ImageNet, ResNet-50 is still:

  • The default backbone for object detection (Faster R-CNN, Mask R-CNN), segmentation (DeepLab, Mask R-CNN), pose estimation.
  • The default transfer-learning starting point for low-data domains (medical imaging, satellite, manufacturing).
  • The default comparison baseline in vision papers.

Why: pre-trained weights are widely available, behavior is well-understood, and the inductive biases (translation equivariance, locality) help when data is limited.

Common pitfalls

  • Skipping the projection on dimension changes. When channels change, you must project via conv before adding.
  • Using ResNet without pretrained weights for small data. Training from scratch on small datasets gives poor results; almost always pretrain on ImageNet first.
  • Adding BN after the residual sum. The residual sum should usually come before the final activation/normalization in a block; placement matters.
  • Treating ResNet-50 as outdated. In 2026 it’s still the practical default for many transfer-learning workloads.