Computer vision & ResNet Part 4

Part 4 · 2015 to 2016

Deep residual learning

He, Zhang, Ren and Sun, December 2015. Stop asking layers to learn the identity, and depth stops being a constraint.

Paper: Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun (Microsoft Research Asia). arXiv:1512.03385, December 2015. CVPR 2016 Best Paper.

Related notes: Classical era and Neural lineage cover how the field arrived here, and The challenge covers the degradation problem in more depth than the summary below.

Background: how vision got deep

Before 2012, image classification was mostly hand-engineered features (SIFT, HOG) fed into a shallow classifier like an SVM. The pipeline was designed by humans; only the last stage was learned. Then a fast sequence of ImageNet (ILSVRC) results changed that:

Year Model Learned layers ImageNet top-5 error Key contribution
2011 hand-crafted features + SVM ~1 ~25.8% pre-deep-learning baseline
2012 AlexNet 8 15.3% ReLU, dropout, GPU training at scale
2013 ZFNet (Clarifai) 8 ~11.2% better hyperparameters, filter visualization
2014 VGG-16/19 16, 19 7.3% uniform 3x3 convs, depth as the headline
2014 GoogLeNet / Inception 22 6.7% inception modules, 1x1 bottlenecks
2015 ResNet-152 152 3.57% (ensemble) residual/skip connections

The trend was obvious: deeper was better. VGG made this the explicit thesis, showing that stacking many small 3x3 filters beat using fewer large ones. So the natural question by 2015 was "is learning better networks as easy as stacking more layers?"

Obstacle 1: vanishing and exploding gradients (mostly solved by 2015)

Gradients shrink or blow up multiplicatively as they backpropagate through many layers. By the time of this paper, this was largely handled by two things:

With these, very deep plain networks would at least converge. They just converged to something bad, which was the real puzzle.

Obstacle 2: the degradation problem (the paper's actual target)

He et al. observed that once deep plain networks converged, accuracy saturated and then got worse with more layers. On CIFAR-10, a 56-layer plain CNN had higher error than a 20-layer one, and critically the training error was higher too. That rules out overfitting, which would show up as low training error and high test error. Something was wrong with optimization itself.

They pinned the paradox with a thought experiment. Take a trained shallow network and build a deeper one by appending extra layers that compute the identity function. This deeper network can, by construction, achieve exactly the shallow network's error. So a good solution always exists. If SGD cannot find a solution at least that good, the problem is that the solver struggles to learn identity mappings through a stack of nonlinear layers.

The core idea

FigurePlain block versus residual block

Loading figure. It needs JavaScript; the surrounding text stands on its own without it.

The only difference is the arrow on the left. It carries the input forward unchanged, costs no parameters and no meaningful compute, and it changes the target of the two convolutions from "compute the right answer" to "compute the correction to the input." Switch to the bottleneck view for the block used in ResNet-50 and deeper.

Rather than asking a stack of layers to directly fit a target function H(x), let it fit the residual F(x) = H(x) - x, and recover the target by adding the input back:

The addition is done element-wise via a shortcut (skip) connection that carries x forward unchanged. The hypothesis: if the optimal mapping is close to the identity, it is far easier for the solver to push the residual weights toward zero than to construct an identity mapping from scratch. Degenerating a block to a no-op becomes the default behavior instead of something that has to be learned.

Two properties made this immediately practical:

  1. Identity shortcuts are parameter-free and add negligible compute, so a residual network has essentially the same cost as the plain network it is built from. Comparisons are apples-to-apples.
  2. Nothing about training changes. Same SGD with backprop, no new losses, no auxiliary classifiers (which GoogLeNet needed), no gating.

Handling dimension changes

Shortcuts only add cleanly when input and output shapes match. When a stage halves spatial resolution and doubles channels, the paper evaluates three options:

B beat A slightly, C beat B marginally but added parameters and memory for little gain, so the released architectures use B. The takeaway is that the win comes from the shortcut topology, not from extra parameters.

Block types

Each conv is followed by BatchNorm, then ReLU, with the addition happening before the final ReLU of the block. Other inherited design rules: 3x3 convs, downsample by stride 2, double channel count when spatial size halves, and global average pooling instead of large fully-connected layers (borrowed from Network-in-Network and GoogLeNet).

Cost comparison worth remembering: ResNet-152 is about 11.3 GFLOPs with ~60M parameters, which is lower complexity than VGG-19 at ~19.6 GFLOPs, and VGG-16 alone carries 138M parameters. Deeper turned out to be cheaper.

Results

FigureAccuracy against cost, and why depth got cheaper

Loading figure. It needs JavaScript; the surrounding text stands on its own without it.

ResNet-152 sits down and to the left of VGG-16: better accuracy for less compute. Switch to the parameter axis to see the effect at its most extreme, where ResNet-152 uses under half of VGG-16's parameters. Circle area is parameter count. Values are from the paper's Table 3, 10-crop validation testing.

Training recipe, for reference: SGD with momentum 0.9, batch size 256, learning rate 0.1 divided by 10 on plateau, weight decay 1e-4, ~600k iterations, BatchNorm, no dropout, scale augmentation, 10-crop and fully convolutional multi-scale testing.

Relation to prior work

Shortcut connections were not new. LSTM (1997) used a gated constant error carousel for the same reason, and Highway Networks (Srivastava, Greff, Schmidhuber, 2015) had already proposed shortcuts for very deep feedforward nets using learned gates:

The difference is that Highway gates are data-dependent and parametric, so they can close and cut off information, and in practice Highway Networks did not show accuracy gains at extreme depth. ResNet's shortcuts are ungated, parameter-free, and always open. All information is always preserved, and the residual branch can only add to it. Stripping out the gate is the whole trick.

Why it still matters

The one-line summary: the arc is AlexNet proving depth works, VGG pushing depth to ~19 layers, and ResNet removing depth as a constraint by changing what each block is asked to learn.