1 Fifty layers, sixteen shortcuts
A stem (a 7×7 convolution and a max-pool) shrinks the photo to 56×56. Then come four
stages of 3, 4, 6 and 3 bottleneck blocks. Each block squeezes its input to a
quarter of the channels with a 1×1 convolution, does a 3×3 convolution there, and expands back
with another 1×1 convolution. The result, F(x), is added to the block's input
x. A block that has nothing to add can output almost zero and pass its input
through unchanged. That is why so many layers can be stacked without the signal fading.
At the end, the 7×7×2048 map is averaged into one vector, and a single linear layer turns it
into 1,000 class scores.
Every convolution is followed by batch normalisation, which rescales each channel to the statistics it had over the training set. In the exported graphs it is folded into the convolution weights, as it is in any deployed model. 25.6 million parameters in total, against VGG16's 138 million.
Layer by layer
2 Dissect an image
Pick, drop, paste or upload an image. The bars on the right show one bottleneck block each:
how large its correction ‖F(x)‖ is compared with what reaches it through the
shortcut. In the first two stages every block only adjusts its input, adding a correction
half to nine-tenths its size. From layer3 on the corrections grow, and in
layer4 most blocks add as much as they pass on, or more. The network keeps the
early description of the image largely intact and rewrites it near the end, where it turns
into an answer. That pattern held on all four samples we measured.
What ResNet-50 sees
Where it looks (class activation map)
Because the head is just an average followed by one linear layer, the class score is exactly the average of this map plus a bias. For ResNet, Grad-CAM and the original CAM are the same thing. Try the astronaut: ResNet-50 also calls her a bobsled.
What each block adds ‖F(x)‖ / ‖shortcut‖
3 Texture is often enough
ImageNet can largely be solved by recognising stuff (fur, feathers, chrome, crema) rather than the shapes of things. Geirhos et al. (2019) showed that ImageNet-trained CNNs, ResNet-50 included, side with texture when shape and texture disagree. You can see it here: cut the image into tiles, shuffle them, and watch how little the prediction cares.
Shuffled
Measured on the six samples with five shuffles each: the cat in a 4×4 shuffle is still "Egyptian cat" every time, at 83% instead of 75% unshuffled. The moped survives a 4×4 shuffle in all five runs for ResNet-50 but only once for VGG16. At 8×8 the tiles are 28 pixels across and every prediction breaks, partly because the new tile edges are themselves strong features. The rocket and the brick building, recognised by their outline, already break at 2×2.
4 Same photos, same residues
Here is the comparison that matters for the traces of the training data. Below, each class is visualised twice, by maximising its logit in VGG16 (left) and in ResNet-50 (right), with the same recipe. The architectures share nothing but the training photos. Whatever shows up in both comes from the photos.
What individual channels detect, stage by stage
The same technique on single channels (pre-activation, 24 evenly spaced channels per stage).
Dream it live
The gradient for this comes from an ONNX graph that PyTorch traced, backward pass included. Unlike VGG16, nothing about ResNet's backward pass was written by hand (see the README). Each step is one forward and one backward pass through all 50 layers.
Offline render
When the gallery has a render of this objective, it appears here.