π§± ResNet & Skip Connections
333 words
2 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# π§± ResNet & Skip Connections ## 1. π― Learning Objectives - Explain the degradation problem in very deep networks - Implement a residual block - Describe ResNet architectures (ResNet-18, 34, 50, 101, 152) - Understand bottleneck design for efficiency ## 2.

π§± ResNet & Skip Connections
1. π― Learning Objectives
- Explain the degradation problem in very deep networks
- Implement a residual block
- Describe ResNet architectures (ResNet-18, 34, 50, 101, 152)
- Understand bottleneck design for efficiency
2. π Core Content
3.1 The Degradation Problem
Intuitively, deeper networks should perform at least as well as shallower ones β if we add identity layers, the deeper network should match the shallower one. But in practice, deeper networks had HIGHER training error. This is the degradation problem, NOT caused by overfitting.
3.2 Residual Block
Idea: Instead of learning H(x) directly, learn the residual F(x) = H(x) - x, then:
If identity is optimal (H(x) = x), the network can set F(x) = 0, which is easier than learning identity directly.
Forward pass: y = ReLU(F(x) + x) where F(x) = WβΒ·ReLU(WβΒ·x + bβ) + bβ
3.3 Why It Works
- Gradient highway: Gradient flows directly through the skip connection (the + x path), bypassing weight layers
- Easier optimization: Residual functions are closer to zero than direct mappings
- Ensemble effect: ResNets behave like ensembles of shallower networks
3.4 ResNet Architectures
| Architecture | Layers | Key Design | Parameters |
|---|---|---|---|
| ResNet-18 | 18 | Basic blocks (2Γ3Γ3 conv) | 11M |
| ResNet-34 | 34 | Basic blocks | 22M |
| ResNet-50 | 50 | Bottleneck blocks (1Γ1, 3Γ3, 1Γ1) | 26M |
| ResNet-101 | 101 | Bottleneck | 45M |
| ResNet-152 | 152 | Bottleneck | 60M |
3.5 Bottleneck Block
For deeper ResNets, use 3 layers: 1Γ1 (reduce channels) β 3Γ3 (spatial) β 1Γ1 (restore channels). This is more efficient than two 3Γ3 layers.
4. π Practice Questions
Q1: A ResNet has a residual block with input 256 channels. The bottleneck reduces to 64 channels for 3Γ3 conv, then back to 256. How many parameters does this block save compared to two 3Γ3 convs with 256 channels?Answer: Bottleneck: 1Γ1(256β64) + 3Γ3(64β64) + 1Γ1(64β256) = 256Γ64 + 9Γ64Γ64 + 64Γ256 = 16,384 + 36,864 + 16,384 = 69,632 params. Two 3Γ3(256β256): 2 Γ 9 Γ 256 Γ 256 = 1,179,648 params. Bottleneck is ~17x more efficient! Join Discord PreviousCNN ArchitecturesNextRNN Variants