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.
In WeightSpace
Read-only in WeightSpace today. Models built from residual blocks are edited at their output layer, after the last block.
Models built as a Residual block
- Read a facial expressionOpenCV Zoo MobileFaceNet1.2M params
- Find video shot changesTransNetV27.6M params
- Clean noise from a photoKAIR Color DnCNN668K params
- Brighten a low-light photoSCI (CVPR 2022)264 params
- Track body joints in a photoMediaPipe BlazePose4.3M params
- Track fingertips in a photoMediaPipe Hand Landmarker2.0M params
- Turn a photo into a mosaicFast Neural Style Mosaic1.7M params