Modern CNN Architectures
After this lesson, you will be able to:
- Trace the CNN family tree from LeNet (1998) to ConvNeXt (2022) and explain what each architecture contributed, not just what it looked like
- Understand why ResNet's skip connections solved the depth degradation problem and why almost every modern network borrowed them — including transformers
- Compare parameter count, FLOPs, and accuracy across architectures so you can pick the right backbone for a given latency/accuracy budget
- Apply EfficientNet's compound scaling principle (depth × width × resolution) when you need to make a model bigger or smaller without doing it ad-hoc
- Recognize when MobileNet-style depthwise separable convolutions are the right tool for edge deployment, and when ConvNeXt-style modernized convs beat ViTs at the same FLOPs
Before you start
Don't worry if the names blur together at first — every one of these architectures was the answer to one specific question, and once you know the question, the answer makes sense.
#A Family Tree of Big Ideas
#LeNet-5 (1998): Where It All Started
LeNet-5 was Yann LeCun's CNN for reading handwritten digits on bank checks. The pattern it set is still the bones of every modern CNN:
Input (32×32)
→ Conv (6 filters, 5×5) → AvgPool (2×2)
→ Conv (16 filters, 5×5) → AvgPool (2×2)
→ Flatten
→ FC (120) → FC (84) → Output (10 classes)
About 60K parameters. Trained on a CPU for days. The recipe — alternating convolutions and pooling, then flatten and feed to a classifier — has not changed in 26 years. What changed is everything else: bigger filters, more channels, more layers, better activations, normalization, residual connections, and a thousand training tricks.
#AlexNet (2012): The Big Bang
AlexNet kept LeNet's blueprint but made everything bigger and meaner:
- 8 layers (5 conv + 3 FC), 60M parameters — 1000× LeNet
- ReLU instead of tanh — trained ~6× faster with no saturation problem
- Dropout in the FC layers — first practical use, prevented overfitting on 1.2M images
- Data augmentation (random crops, horizontal flips, PCA color jitter)
- Two GPUs with model parallelism (NVIDIA GTX 580, 3GB each) — the model literally did not fit on one card
- Local Response Normalization (later abandoned, but it worked at the time)
#VGG (2014): Depth Wins, Simplicity Wins
- VGG-16: 16 weighted layers, 138M parameters
- VGG-19: 19 weighted layers, 144M parameters
- All filters 3×3, all max-pools 2×2
The cost: VGG was huge and slow. The FC layers alone had 100M+ parameters. Modern networks dropped them in favor of global average pooling.
#GoogLeNet / Inception (2014): Width Without the Bill
- 22 layers deep, but only 5M parameters (compared to VGG's 138M)
- Auxiliary classifiers attached to intermediate layers, gradient injection during training
- The 1×1 conv idea was reused everywhere thereafter (ResNet bottleneck, MobileNet, transformer FFN)
#ResNet (2015): The Skip-Connection Revolution
Interactive Lab
Toggle skip connections on and off on a 30-layer net and watch gradient magnitudes plummet without them — the exact problem ResNet solved.
H(x), ask it to learn the residual F(x) = H(x) − x, and add x back:Why does adding x back help so much? Open the derivation to see the gradient split into two paths, one of which never shrinks. It assumes nothing but the addition follows the block, which is the clean form studied in He et al.'s follow-up paper. The original block applies a ReLU after the addition.
ResNet variants you will see in the wild:
- ResNet-18 / 34: basic residual blocks, no bottleneck
- ResNet-50 / 101 / 152: bottleneck blocks (1×1 → 3×3 → 1×1) for efficiency
- ResNeXt: groups of parallel residual paths (cardinality > 1) — Facebook 2016
- Wide ResNet: shorter but wider, sometimes beats deeper variants on small datasets
How much does the 1×1 to 3×3 to 1×1 bottleneck save? Open the derivation and count the weights for a layer with 256 channels.
Try it! Open the Python REPL and type these lines yourself:import torchvision.models as m; r = m.resnet50(weights="IMAGENET1K_V2"); print(sum(p.numel() for p in r.parameters())/1e6, "M params")— you get a 25.5M-parameter ImageNet-pretrained ResNet-50 in two lines.
#DenseNet (2016): Reuse Everything
- Strong gradient flow (every layer is one hop from the loss)
- Strong feature reuse (early features always available to later layers)
- Surprisingly parameter-efficient — DenseNet-121 matches ResNet-50 with half the parameters
- Memory-hungry to train (concatenation grows the tensor) — that's the tradeoff
DenseNet is less common in production than ResNet, but its core idea — exposing all features to all later layers — shows up in U-Net skip connections, transformer cross-attention, and modern feature pyramid networks.
#MobileNet (2017): Tiny Models for Phones
- Depthwise: one 3×3 filter per input channel, applied independently. No mixing across channels.
- Pointwise: a 1×1 conv that mixes channels.
9 · M · N · D² multiplications. The depthwise separable replacement costs 9 · M · D² + M · N · D² — typically 8–9× cheaper for the channel counts used in real networks.Where does 1/N + 1/D_K^2 come from? Open the derivation and count the multiplications of each piece.
Set the kernel to 3 and both channel counts to 64, then widen C_out and watch the ratio sink toward 1/9.
MobileNet variants (V1 → V2 → V3) added inverted residuals, linear bottlenecks, hard-swish activations, and squeeze-and-excitation blocks. They remain the default backbone for on-device vision: phone cameras, AR headsets, smart doorbells.
#EfficientNet (2019): Scale Smart, Not Just Big
Why does the constraint use beta squared and gamma squared but only a plain alpha? Open the derivation. It follows how the cost of a convolution layer changes when each of the three dials turns.
#ConvNeXt (2022): The Empire Strikes Back
They took a vanilla ResNet-50 and modernized it piece by piece, borrowing transformer-era tricks:
- LayerNorm instead of BatchNorm
- GELU instead of ReLU
- Larger 7×7 depthwise kernels (matching the receptive field of an attention head)
- Inverted bottleneck (channel expansion in the middle, like MobileNet V2)
- Fewer activations and norms per block
You train a 50-layer plain CNN on ImageNet from scratch. Then you train a 50-layer ResNet (same depth, same params) with the same hyperparameters. Both networks have enough capacity to overfit the data. What happens?
#A Working Comparison
This code needs PyTorch, and in places a GPU, so it cannot run on this page. Copy it to Google Colab to run it.
# Copy to Colab: needs torch, so it cannot run on this page.
# Compare param counts and depths across the CNN family.
# We will load each architecture from torchvision and report its size.
# Then we will build a single ResNet block from scratch.
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.models as models
def count(m):
return sum(p.numel() for p in m.parameters()) / 1e6
# Survey the family tree
zoo = [
("AlexNet (2012)", models.alexnet),
("VGG-16 (2014)", models.vgg16),
("GoogLeNet (2014)", models.googlenet),
("ResNet-50 (2015)", models.resnet50),
("DenseNet-121 (2016)", models.densenet121),
("MobileNet-V3-S (2019)",models.mobilenet_v3_small),
("EfficientNet-B0 (2019)",models.efficientnet_b0),
("ConvNeXt-Tiny (2022)", models.convnext_tiny),
]
print(f"{'Architecture':<25} {'Params (M)':>12}")
print("-" * 38)
for name, ctor in zoo:
net = ctor(weights=None) # uninstantiated random init for counting
print(f"{name:<25} {count(net):>12.2f}")
# Build a ResNet basic block from scratch
class BasicResBlock(nn.Module):
def __init__(self, c):
super().__init__()
self.conv1 = nn.Conv2d(c, c, 3, padding=1, bias=False)
self.bn1 = nn.BatchNorm2d(c)
self.conv2 = nn.Conv2d(c, c, 3, padding=1, bias=False)
self.bn2 = nn.BatchNorm2d(c)
def forward(self, x):
identity = x
out = F.relu(self.bn1(self.conv1(x)))
out = self.bn2(self.conv2(out))
out = out + identity # skip connection — the whole point
return F.relu(out)
block = BasicResBlock(64)
x = torch.randn(2, 64, 32, 32)
print()
print(f"Input shape : {tuple(x.shape)}")
print(f"Output shape: {tuple(block(x).shape)}")
print(f"Block params: {count(block) * 1e6:.0f}")
print()
print("CHALLENGE: implement a depthwise-separable conv block")
print("(MobileNet-style) and compare its param count to a")
print("standard 3x3 conv with the same in/out channels.")Notes for going further:
# class DSConv(nn.Module):
# def __init__(self, c_in, c_out, stride=1):
# super().__init__()
# self.dw = nn.Conv2d(c_in, c_in, 3, stride=stride,
# padding=1, groups=c_in, bias=False)
# self.pw = nn.Conv2d(c_in, c_out, 1, bias=False)
# self.bn = nn.BatchNorm2d(c_out)
# def forward(self, x):
# return F.relu(self.bn(self.pw(self.dw(x))))
# A standard 3x3 with c_in=128, c_out=128 has 128*128*9 = 147K params.
# The depthwise-separable equivalent has 128*9 + 128*128 = 17.5K — about 8x cheaper.What to check: Verify that the parameter counts roughly match the published numbers and that the residual block preserves spatial shape.
#Key Takeaways
- Each CNN architecture answered one specific question. LeNet (do convs work?), AlexNet (do they scale?), VGG (does depth help?), ResNet (how do we go really deep?), MobileNet (can they fit on a phone?), EfficientNet (how do we scale principled?), ConvNeXt (are convs really obsolete?).
- ResNet's skip connection is the single most-borrowed idea in deep learning. It lives in every transformer block, every diffusion U-Net, AlphaFold, WaveNet, and modern recurrent nets; the trick is changing the optimization landscape so gradients can flow, not adding capacity.
- Compound scaling beats one-axis scaling. EfficientNet's depth · width · resolution rule replaced "just make it deeper," and the same principle later guided LLM scaling laws.
- Depthwise separable convolutions are an ~8× FLOP saver for mobile but check wall-clock latency on real hardware — they can be bandwidth-limited on GPUs.
- "Transformers beat convs" was partly a training-tricks story. ConvNeXt showed that modernizing a ResNet with LayerNorm, GELU, and large kernels closes the gap; architecture and recipe are deeply coupled.
#Quick Check
Why did plain networks (no skip connections) deeper than ~20 layers actually perform WORSE than shallower ones in 2014, before ResNet?