ResNet (Residual Network)

Machine Learning
Introduced by
He, K.; Zhang, X.; Ren, S.; Sun, J.
Year
2016
Type
Deep Convolutional Neural Network with skip connections

What does it do?

ResNet (Residual Network) is a deep convolutional neural network introduced by Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun, presented at CVPR 2016.

It adds shortcut (skip) connections that carry a block's input directly to its output, so each block learns a residual correction to its input rather than a complete mapping. The authors report that this made networks of up to 152 layers on ImageNet easier to optimise than plain stacked networks of the same depth, and they also analysed residual networks with 100 and 1000 layers on CIFAR-10. An ensemble of residual nets reached 3.57% top-5 error and won first place in the ILSVRC 2015 classification task.

The intuition behind the method

Plain networks become harder to optimise as depth grows. The paper's central observation is that deeper plain networks show higher training error, a degradation problem distinct from overfitting. Gradients passing backward through many layers can also become small, which makes early layers slow to learn. ResNet changes what each block has to learn. Instead of asking a block to produce the desired output H(x) directly, the input x bypasses the block through a shortcut, and the block learns only the residual F(x) = H(x) - x. If the best output is close to the input, the residual is near zero, which is an easier target than the full mapping. The shortcut also gives the gradient a direct additive path from the loss back toward earlier layers.

History

Before ResNet, deep plain networks were hard to train, and He et al. (2016) observed that deeper plain networks showed higher training error, a degradation distinct from overfitting. They proposed residual learning as the remedy; the work appeared as a 2015 arXiv preprint and was published at CVPR 2016. The ensemble of residual nets reached 3.57% top-5 error on ILSVRC 2015 and won first place in that classification task, along with first places on the detection, localisation, and COCO tasks listed in the paper. ResNet backbones were subsequently used in detectors such as Faster R-CNN and Mask R-CNN, and variants such as Wide ResNets, ResNeXt, and Pre-activation ResNet followed.

When to use it

Choose ResNet when the task is image-based (classification, detection, segmentation, or feature extraction) and accuracy matters more than minimal inference cost. Pre-trained ImageNet weights are publicly available for the standard variants, which makes transfer learning practical when the labelled target dataset is small, usually through fine-tuning. ResNet-18 and ResNet-34 suit tighter compute budgets, while ResNet-50 to ResNet-152 suit accuracy-first settings. Avoid ResNet as a default for real-time or embedded deployment without compression or a lighter architecture, and for tabular, sequential, or text data, where other architectures are usually preferred.

Limitations and considerations

  • Heavier than lightweight architectures such as MobileNet or EfficientNet-B0. Even the smaller variants need compression or a different design for real-time use on constrained hardware.
  • The architecture is built around convolutional image tensors, so non-image inputs such as tabular or sequential data require different designs.
  • Pre-trained weights reflect ImageNet categories and image statistics. Transfer to domains such as medical or remote-sensing imagery can require substantial fine-tuning or domain-specific pre-training.
  • Skip connections do not guarantee that greater depth improves accuracy. Very deep residual networks should therefore be compared against shallower ones on the target task before the extra depth is adopted.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Identity shortcuts let the paper's deep variants, up to 152 layers on ImageNet, be optimised more readily than plain networks of the same depth.
  • An ensemble of residual nets reached 3.57% top-5 error on ILSVRC 2015 and won that classification task; the paper also reports first places on ImageNet detection and localisation and on COCO detection and segmentation.
  • Pre-trained ImageNet weights support transfer learning when the target dataset is small.
  • The same residual pattern spans a range of depths, from ResNet-18 and ResNet-34 with basic blocks to ResNet-50 and deeper with bottleneck blocks, giving a range of compute-accuracy trade-offs.
  • Implementations are available in major deep-learning frameworks such as PyTorch, TensorFlow/Keras, and JAX.

Applications

  • Image classification on large-scale benchmarks such as ImageNet, the dataset on which ResNet was evaluated.
  • Backbone for object detectors such as Faster R-CNN and Mask R-CNN.
  • Semantic and instance segmentation; some U-Net-style variants use a ResNet encoder.
  • Transfer learning for medical image analysis, satellite imagery, and industrial inspection, using pre-trained features and fine-tuning.
  • Feature extraction for retrieval and recognition tasks, including face and action recognition.

How it works

How it works

1

The basic building block adds a skip connection that bypasses a group of convolutional layers. The residual branch F(x, {W_i}) is typically two 3×3 convolutions with batch normalisation and ReLU, and the block output is y = F(x, {W_i}) + x before the final activation. Because the identity is built in, the block approximates an identity mapping simply by driving the residual branch toward zero.

Formula
\mathbf{y} = \mathcal{F}(\mathbf{x},\, \{W_i\}) + \mathbf{x}
2

When a block changes the shape of its input, for example when a strided convolution halves spatial resolution or the number of channels increases, the identity shortcut cannot be added directly. A learned linear projection W_s, usually implemented as a 1×1 convolution, matches x to the dimensions of F(x): y = F(x, {W_i}) + W_s x. Only blocks where the dimensions change use this projection.

Formula
\mathbf{y} = \mathcal{F}(\mathbf{x},\, \{W_i\}) + W_s\,\mathbf{x}
3

The deeper variants (ResNet-50, 101, 152) replace the two-layer block with a three-layer bottleneck: a 1×1 convolution that reduces channel depth, a 3×3 convolution at the reduced depth, and a 1×1 convolution that restores the original depth. The design aims to keep computational cost close to that of the two-layer block while allowing a deeper network.

4

During the forward pass, activations propagate as x_{l+1} = x_l + F(x_l, {W_i^l}). Because the shortcut is an identity, each layer's activation is the input representation plus the residual corrections accumulated from earlier layers, so the original representation remains directly available to deeper layers.

Formula
\mathbf{x}_{l+1} = \mathbf{x}_l + \mathcal{F}(\mathbf{x}_l,\, \{W_i^l\})
5

During backpropagation the gradient with respect to an earlier activation contains a term of 1 from the identity shortcut, as the formula shows. This additive term means the gradient is not only a product of layer Jacobians, which can shrink toward zero, so the training signal can still reach the early layers of a deep network.

Formula
\frac{\partial \mathcal{L}}{\partial \mathbf{x}_l} = \frac{\partial \mathcal{L}}{\partial \mathbf{x}_L}\cdot\left(1 + \frac{\partial}{\partial \mathbf{x}_l}\sum_{i=l}^{L-1}\mathcal{F}(\mathbf{x}_i,\,\{W_i\})\right)

Common pitfalls

  • Fine-tuning with the learning rate used for training from scratch. Pre-trained weights generally need a smaller learning rate so that useful features are not overwritten early in training.
  • Freezing the whole backbone when the target domain differs strongly from ImageNet, which limits how far the features can adapt.
  • Using very small mini-batches with batch normalisation, which makes the batch statistics noisy and can destabilise training and degrade performance.
  • Choosing ResNet-152 by default when a smaller variant such as ResNet-50 meets the accuracy requirement, at a much higher compute cost.
  • Fine-tuning a deep variant on a small labelled set without data augmentation, which increases the risk of overfitting even when the backbone is pre-trained.

Frequently asked questions

Which ResNet variant should I choose?

ResNet-18 and ResNet-34 use the basic two-layer block and are the cheapest variants, suited to tighter compute budgets, though they are still heavier than lightweight architectures. ResNet-50 is a common trade-off between accuracy and compute. ResNet-101 and ResNet-152 suit accuracy-first settings where more compute is available. For mobile or edge deployment, consider lighter architectures such as MobileNetV3 or EfficientNet-B0, or compress a ResNet with pruning.

Do I need to train ResNet from scratch?

Rarely, for standard image tasks. Pre-trained ImageNet weights are publicly available for the standard variants and are a common starting point for transfer learning. Fine-tuning the final layers, or the whole network at a small learning rate, is usually the first step. Training from scratch is more reasonable when the target domain differs greatly from ImageNet and a large labelled dataset is available.

Why does ResNet outperform plain deep networks of the same depth?

He et al. (2016) show that plain networks have higher training error as depth increases, so the difficulty is optimisation rather than overfitting. Identity skip connections make it easier to learn residuals rather than full mappings, and they provide a gradient path through the identity term, so deeper residual networks can benefit from their extra depth.

Is ResNet still competitive with modern architectures?

ResNet-50 and ResNet-101 remain common baselines and backbones in detection and segmentation pipelines. Newer architectures such as EfficientNet, Vision Transformers, and ConvNeXt are often reported with better accuracy-efficiency trade-offs on classification, but ResNet is still often chosen for its simplicity, stability, and the many established downstream pipelines built around it.

Related methods

Sources

  1. He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep Residual Learning for Image Recognition. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 770–778.

    Open DOI reference
  2. He, K., Zhang, X., Ren, S., & Sun, J. (2015). Deep Residual Learning for Image Recognition. arXiv:1512.03385.

    Open publication reference
  3. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning (Ch. 9: Convolutional Networks). MIT Press.

    ISBN: 978-0-262-03561-3
  4. 2018_Book_NeuralNetworksAndDeepLearning, p. ?