Residual block

Convolutional · pattern · Image → Image, Scores

Two convolutions whose output is added back to their input, so very deep networks stay trainable.

Also called ResNet block, Basic block, Skip block

Figure 1. The Residual block as a schematic: the parts it is built from and how data flows between them. Select a part to read about it.

What it does

A residual block computes a correction F(x) with two convolutions, normalization and an activation, then adds the untouched input x back before the final activation. Because the block starts close to the identity, adding more blocks rarely hurts, and gradients reach early layers through the shortcuts. When the block changes resolution or channel count, the shortcut gets a 1 × 1 convolution with matching stride. Networks are usually built from stages of identical blocks.

Formula

F(x) = BN(Conv(ReLU(BN(Conv(x)))))y = ReLU(x + F(x))

Shapes and parameters

Shapes
Input and output have the same shape, here [N, 64, H, W]; a downsampling block halves H and W and doubles the channels.
Parameters
Two 3 × 3 convolutions with C channels (C × C × 9 each, usually without bias) plus 2 × 2C normalization values. For C = 64: 73,728 + 256 = 73,984.
Used for
ResNet backbones, many detection and depth backbones, DnCNN and other image restoration models, residual U-Nets.

Figure 2. A real residual block in WeightSpace: Brighten a low-light photo, drawn from the file the app runs. Open a module to see the parts inside.

In WeightSpace

Read-only in WeightSpace today. Models built from residual blocks are edited at their output layer, after the last block.