The Residual Block Architecture
What you'll learn: You'll understand the practical structure of a basic residual block—the fundamental building unit of ResNet architectures.
Anatomy of a Residual Block
A residual block is the concrete implementation of skip connections in ResNet. The most basic version consists of two sequential 3×3 convolutional layers with a skip connection that bypasses them.
Here's the structure:
- Main path: Input → Conv 3×3 → BatchNorm → ReLU → Conv 3×3 → BatchNorm
- Skip connection: Input directly forwarded (identity mapping)
- Merge: Add main path output to skip connection
- Final activation: ReLU applied to the sum
The key innovation is the addition operation that combines the transformed features (main path) with the original input (skip connection). This allows gradients to flow backward through both paths during training.
Why This Design?
The two 3×3 convolutions provide the block's learning capacity—they can extract features and transform the input. Meanwhile, the skip connection ensures that if the block doesn't need to learn anything complex, it can simply pass the input through unchanged. This makes training deep networks dramatically easier.
Think of it like editing a document: instead of rewriting everything from scratch (standard layers), you make small corrections to the original (residual learning). The "corrections" are what the convolutional layers learn.
Dimensions Matter
For the addition to work, the skip connection and main path must produce outputs with identical dimensions. When dimensions change (like reducing spatial size or increasing channels), the skip connection uses a 1×1 convolution to match dimensions—this variant is called a "projection shortcut."
Key Takeaway: A basic residual block stacks two 3×3 convolutions with batch normalization and ReLU, then adds the input via a skip connection, enabling easier training of very deep networks by learning corrections rather than complete transformations.