1. Home
  2. Explore
  3. Computer Science
  4. CNN Architectures

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

CNN Architectures

CNN Architectures

This lecture covers the most influential convolutional neural network (CNN) architectures that have set benchmarks on the ImageNet classification challenge, from the pioneering AlexNet (2012) through to ResNet (2015) and beyond. The focus is on understanding the key design innovations—depth, filter size, computational efficiency, and connectivity—that drove performance improvements. These architectures are the foundation for modern computer vision applications and transfer learning.


LeNet: The First Successful CNN

Before the deep architectures, LeNet (1989) demonstrated the first practical use of CNNs for digit recognition. Its structure was simple: an input image, alternating convolutional layers (5×5 filters, stride 1) and pooling layers, followed by fully connected layers. This basic pattern—conv + pool + FC—became the template for all later networks.


AlexNet (2012)

AlexNet was the first large-scale CNN to win the ImageNet classification challenge, dramatically outperforming all non‑deep learning methods. It essentially scaled up LeNet with more layers and parameters.

Architecture Overview

  • Input: 227×227×3 images (the original paper states 224×224, but 227 produces correct dimensions).

  • Layers: 5 convolutional layers, 3 pooling layers, 3 fully connected layers (including the final 1000‑way softmax).

  • First conv layer: 96 filters of size 11×11, stride 4.

    • Output volume: 55×55×96 (using 227−114+1=55\frac{227 - 11}{4} + 1 = 554227−11​+1=55).

    • Parameters: 96×11×11×3=34,84896 \times 11 \times 11 \times 3 = 34,84896×11×11×3=34,848 (each filter has depth 3 covering the input channels).

  • Second layer: Max‑pooling with 3×3 filters, stride 2 → 27×27×96 (pooling has no learnable parameters).

  • Subsequent layers use 5×5 and 3×3 filters, with increasing depth.

Key Contributions and Training Details

  • ReLU nonlinearity: First use of ReLU, which accelerates training compared to tanh/sigmoid.

  • Local Response Normalization (LRN): Normalizes responses across channels, but later found to have minimal effect and is rarely used today.

  • Heavy data augmentation: Flipping, jittering, cropping, color normalization to reduce overfitting.

  • Dropout: Applied in the fully connected layers.

  • Training: SGD with momentum (0.9), batch size 128, initial learning rate 10−210^{-2}10−2 reduced by factor 10 when validation plateaus, weight decay 5×10−45 \times 10^{-4}5×10−4.

  • Ensembling: Multiple models averaged for final prediction.

  • Dual‑GPU design: The network was split across two GPUs (48 feature maps each) due to memory constraints; some layers connected across GPUs (conv3, FC6‑8), others only within a GPU.

AlexNet had 60 million parameters and achieved a top‑5 error of about 15.3% on ImageNet (2012).


ZFNet (2013)

The 2013 winner ZFNet (Zeiler & Fergus) was essentially an improved AlexNet. It kept the same number of layers but tuned hyperparameters: smaller stride (2 instead of 4) and more filters in early layers. This reduced the top‑5 error to about 11.2%. The architecture itself did not introduce fundamentally new ideas.


VGGNet (2014)

VGGNet (Oxford) placed second in classification but first in localization in the 2014 ImageNet challenge. Its key innovation was increased depth (16–19 weight layers) while using only very small filters (3×3 convolutions throughout).

Why Small Filters?

Stacking three 3×3 conv layers (stride 1) has the same effective receptive field (7×7) as a single 7×7 conv layer, but with advantages:

  • More nonlinearities (three ReLUs instead of one) → more expressive.

  • Fewer parameters: 3×(3×3×C×C)=27C23 \times (3 \times 3 \times C \times C) = 27C^23×(3×3×C×C)=27C2 vs. 7×7×C×C=49C27 \times 7 \times C \times C = 49C^27×7×C×C=49C2 for a 7×7 layer (assuming same input/output depth CCC).

Architecture

  • 16‑layer variant (VGG‑16): 13 conv layers + 3 FC layers. The pattern: conv3‑64 (two layers), pool; conv3‑128 (two layers), pool; conv3‑256 (three layers), pool; conv3‑512 (three layers), pool; conv3‑512 (three layers), pool; FC‑4096, FC‑4096, FC‑1000 (softmax).

  • 19‑layer variant (VGG‑19): Adds one more conv layer in the deeper blocks.

  • All convolutions use 3×3 filters with stride 1 and same padding; max‑pooling of 2×2 with stride 2 halves spatial dimensions.

Memory and Parameters

  • Memory: Forward pass consumes about 100 MB per image (due to large activation maps in early layers). This limits batch size.

  • Parameters: 138 million (VGG‑16) vs. 60 million for AlexNet. Most parameters are in the fully connected layers (early conv layers are small in parameters but large in memory; FC layers are parameter‑heavy).

  • No local response normalization (found unnecessary).

Key Results

  • Top‑5 error: 7.3% (VGG‑16); VGG‑19 slightly better.

  • FC7 features (4096‑dim from the second‑last FC layer) are excellent generic feature representations, widely used for transfer learning.

  • Trained similarly to AlexNet (SGD, data augmentation, ensembling).


GoogLeNet (Inception v1, 2014)

GoogLeNet (Google) won the 2014 classification challenge with a top‑5 error of 6.7%, while being much more parameter‑efficient than VGG. It introduced the Inception module and bottleneck layers to manage computational cost.

The Inception Module

The idea is to apply multiple filter operations in parallel on the same input, then concatenate their outputs depth‑wise. A naive Inception module includes:

  • 1×1 convolution

  • 3×3 convolution

  • 5×5 convolution

  • 3×3 max‑pooling

All operations use padding to preserve spatial dimensions (e.g., 28×28). The outputs are concatenated along the depth axis. This allows the network to capture features at multiple scales within the same layer.

Problem: Naive implementation is computationally expensive. For example, with 28×28×256 input:

  • 1×1, 128 filters → 28×28×128 (efficient)

  • 3×3, 192 filters → 28×28×192 (requires 28⋅28⋅192⋅256⋅3⋅3≈34628\cdot28\cdot192\cdot256\cdot3\cdot3 \approx 34628⋅28⋅192⋅256⋅3⋅3≈346M ops)

  • 5×5, 96 filters → 28×28×96 (requires 28⋅28⋅96⋅256⋅5⋅5≈48028\cdot28\cdot96\cdot256\cdot5\cdot5 \approx 48028⋅28⋅96⋅256⋅5⋅5≈480M ops)

  • 3×3 pooling → 28×28×256 (no learnable parameters, but preserves full depth) Total from conv layers: ~854 million operations.

Moreover, pooling preserves the entire input depth, causing the feature depth to grow rapidly through successive modules.

Bottleneck Layers: 1×1 Convolutions for Dimensionality Reduction

GoogLeNet inserts 1×1 convolutions (bottleneck layers) before the 3×3 and 5×5 convs and after the pooling to reduce depth. For the same example:

  • Before 3×3: 1×1 conv with 64 filters reduces 256 → 64.

  • Before 5×5: 1×1 conv with 64 filters reduces 256 → 64.

  • After pooling: 1×1 conv with 128 filters reduces 256 → 128. The total operations drop to 358 million (less than half). The 1×1 conv acts as a linear combination of input feature maps, followed by a ReLU, which can also help add nonlinearity.

Full Architecture

  • Stem: A few conv/pool layers (7×7, 3×3) to reduce input size.

  • Stack of Inception modules (9 modules, 22 weight layers).

  • No fully connected layers – uses global average pooling before the final softmax, drastically reducing parameters. GoogLeNet has only 5 million parameters (12× fewer than AlexNet).

  • Auxiliary classifiers (two intermediate softmax outputs) injected at mid‑depth to provide additional gradient flow and combat vanishing gradients in the deep network. These are averaged with the final loss during training (with a reduced weight, e.g., 0.3).

Training and Performance

  • Trained with SGD, data augmentation, ensembling.

  • Top‑5 error: 6.7% (2014 winner).

  • The Inception module design was later refined into versions v2, v3, v4 (the latter combined with ResNet).


ResNet (2015)

ResNet (Microsoft Research) introduced residual learning, enabling networks with extraordinary depth (up to 152 layers for ImageNet) and achieving a top‑5 error of 3.57% (surpassing human performance). It swept all ILSVRC and COCO competitions in 2015.

The Degradation Problem

When stacking plain (non‑residual) convolutional layers, deeper networks perform worse than shallower ones on both training and test error. This is not due to overfitting (training error is higher) but because optimization becomes more difficult as depth increases. Theoretically, a deeper model should be at least as good as a shallower one by learning identity mappings in the extra layers.

Residual Learning

Instead of learning the desired mapping H(x)H(x)H(x) directly, each stacked layer learns a residual mapping F(x)=H(x)−xF(x) = H(x) - xF(x)=H(x)−x. The original input xxx is added to F(x)F(x)F(x) via a skip connection (identity shortcut). The output of a residual block is F(x)+xF(x) + xF(x)+x.

If the identity mapping is optimal, the layer can simply learn F(x)=0F(x) = 0F(x)=0 (squash weights to zero), which is easier than learning H(x)=xH(x) = xH(x)=x from scratch. This makes deep networks easier to optimize.

Residual Block Design

  • Basic block (used for ResNet‑34 and below): Two 3×3 conv layers with batch normalization and ReLU, plus the identity connection.

  • Bottleneck block (used for ResNet‑50 and above): To improve efficiency, a 1×1 conv reduces depth (e.g., 256 → 64), then a 3×3 conv operates on the reduced depth, then another 1×1 conv projects back to the original depth (64 → 256). This reduces parameters and computation while allowing deeper networks.

  • All blocks use batch normalization after each conv and before ReLU.

  • When dimensions change (halving spatial size and doubling filters), the shortcut uses a 1×1 conv with stride 2 adjust dimensions, or zero‑padding.

ResNet Architecture (152‑layer example)

  • Stem: Conv 7×7 (64 filters, stride 2) + max‑pool 3×3 (stride 2).

  • Four stages of residual blocks, each with varying numbers of blocks (e.g., 3, 8, 36, 3 for ResNet‑152). Stage transition: spatial size halved (stride 2), filters doubled.

  • Global average pooling before the final 1000‑way softmax (no fully connected layers except the final one).

  • Total layers: 152 (including conv and FC; pooling and activation not counted).

  • Parameters: ~25 million for ResNet‑50, ~60 million for ResNet‑152 (still less than VGG‑16’s 138 million).

Training Details

  • Initialization: Xavier initialization with an additional scaling factor for residual branches.

  • Optimizer: SGD with momentum (0.9), batch size 256, weight decay 10−410^{-4}10−4, no dropout.

  • Learning rate schedule: Start at 0.1, divide by 10 when error plateaus.

  • They successfully trained up to 1202 layers on CIFAR‑10.

Why ResNet Works

  • The identity shortcut creates a direct path for gradient flow during backpropagation, preventing vanishing gradients even in very deep networks.

  • The residual formulation encourages layers to learn small deltas to the identity, making optimization easier.

  • Experimental results showed that deeper ResNets consistently achieve lower training error, solving the degradation problem.


Other Notable Architectures

Network in Network (NiN, 2014)

  • Introduced MLPconv layers (1×1 conv followed by an MLP) to compute more abstract features per local patch.

  • Used global average pooling instead of FC layers (precursor to GoogLeNet and ResNet).

  • Philosophical inspiration for the "network within network" idea.

Improved ResNet (Pre‑activation, 2016)

  • Rearranged the order of batch normalization, ReLU, and convolution inside residual blocks.

  • Full pre‑activation (BN → ReLU → Conv) allows better gradient propagation through the identity path.

  • Achieved improved performance over the original ResNet block design.

Wide Residual Networks (WRN, 2016)

  • Argued that residual connections, not extreme depth, are the critical factor.

  • Made residual blocks wider (e.g., kkk times more filters) instead of deeper.

  • A 50‑layer Wide ResNet (with width factor k=2k=2k=2) outperformed the 152‑layer original ResNet.

  • Wider networks are more computationally efficient because convolution operations can be parallelized across filters, while depth is sequential.

ResNeXt (2017)

  • Combines the ideas of depth, width, and cardinality – the number of parallel pathways within a residual block.

  • Each residual block contains multiple (e.g., 32) thinner parallel paths (similar to an inception module but with same topology).

  • Increasing cardinality improved performance more than increasing depth or width alone.

  • Achieved better accuracy than ResNet with similar compute.

Stochastic Depth (2016)

  • During training, randomly drop entire residual blocks (set them to identity) to create shorter networks.

  • This reduces training time, improves gradient flow, and acts as a regularization similar to dropout.

  • At test time, the full deep network is used.

  • Allowed training very deep networks (e.g., 1202 layers) more effectively.

FractalNet (2016)

  • An alternative to residual networks that uses a fractal architecture (nested, repeating block patterns) with no skip connections.

  • Contains both shallow and deep pathways to the output.

  • Training with dropping out sub‑paths (similar to Stochastic Depth) forces the network to learn representations that work at multiple depths.

  • Achieved comparable accuracy to ResNet, suggesting residual representations are not strictly necessary.

Densely Connected Convolutional Networks (DenseNet, 2017)

  • Each layer connects to every other layer in a feed‑forward manner within a dense block.

  • For a block with LLL layers, the iii-th layer receives all feature maps from layers 0,1,...,i−10,1,...,i-10,1,...,i−1 as input (concatenated).

  • This strengthens feature propagation, encourages feature reuse, and alleviates vanishing gradients.

  • Each layer only adds a small number of feature maps (e.g., k=12k=12k=12 – the growth rate) to keep the model compact.

  • Very parameter‑efficient; DenseNet‑121 has fewer parameters than ResNet‑50 but comparable accuracy.

SqueezeNet (2016)

  • Focused on model efficiency for deployment on resource‑constrained devices.

  • Uses Fire modules: first a squeeze layer (1×1 conv, few filters) then an expand layer (mix of 1×1 and 3×3 conv).

  • Achieves AlexNet‑level accuracy on ImageNet with 50× fewer parameters (∼1.2 million vs. 60 million).

  • After compression (quantization, pruning), can be reduced to 0.5 MB (500× smaller than AlexNet).


Summary and Trends

Architecture

Year

Depth (weight layers)

Key Innovation

Top‑5 Error (ImageNet)

Parameters (approx.)

AlexNet

2012

8

First large‑scale deep CNN, ReLU, dropout

15.3%

60M

VGGNet

2014

16–19

Very deep, small 3×3 filters

7.3%

138M

GoogLeNet

2014

22

Inception module, bottleneck layers, global avg pooling

6.7%

5M

ResNet

2015

152 (up to 1202)

Residual connections, identity shortcuts

3.57%

25–60M

Key takeaways:

  • Deeper networks have become the norm, but depth alone is insufficient – careful design of connections (skip connections, dense connections, parallel paths) is essential for good gradient flow and trainability.

  • Computational efficiency is a major concern: GoogLeNet and ResNet use bottleneck layers; SqueezeNet pushes efficiency further. Fully connected layers are parameter‑heavy and are often replaced by global average pooling.

  • Modern architectures (ResNeXt, DenseNet) often combine multiple innovations: residual connections, parallel paths, dense feature reuse.

  • Transfer learning is standard practice: pretrained models (VGG, ResNet, etc.) are fine‑tuned for specific tasks. The FC7 features from VGG are a classic generic feature representation.

These architectures form the backbone of today’s computer vision systems. When selecting a model for a new task, ResNet is a strong default, but techniques like DenseNet or EfficientNet (a later development) may offer better accuracy‑efficiency trade‑offs depending on the resource constraints.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent