Foundations to Frontier
Tests
E. Deep Learning › E8 CNN Architectures (one page each)

ConvNeXt

ConvNeXt (Liu et al., 2022) asked whether convolutional networks fell behind vision transformers because of convolution itself or because of design and training details. Starting from ResNet-50 trained with a modern recipe (78.8% ImageNet top-1), the authors applied transformer-inspired changes one at a time and reached 82.0% at the same compute, beating Swin-T, with a purely convolutional network. The changes: a patchify stem, stage ratio 3:3:9:3, depthwise convolutions, inverted bottlenecks, 7 × 7 kernels, GELU, fewer activations and normalisations, LayerNorm and separate downsampling. In the exercises you build a ConvNeXt block, then count ConvNeXt-T exactly (28,589,128 parameters, 4.46 G multiply–adds) and show its large kernels cost under 1% of its parameters.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Was it the convolutions, or the recipe?

By 2021 vision transformers were beating ResNets, and many concluded that convolution was outdated. The ConvNeXt authors tested that. They took a ResNet, trained it with the transformers’ modern recipe, and then changed its design step by step to borrow transformer habits: bigger patches at the start, larger filters, wider-then-narrower blocks, different normalisation and activation. Each change kept the network purely convolutional. At the end it matched or beat a transformer of the same size.

Architecture explorer: shapes, parameters and compute
stageoutput C × H × Wparametersmultiply–adds
stem64 × 56 × 56
9.5 k
118.01 M
stage2256 × 56 × 56
215.8 k
667.94 M
stage3512 × 28 × 28
1.22 M
1.03 G
stage41024 × 14 × 14
7.10 M
1.46 G
stage52048 × 7 × 7
14.96 M
809.24 M
head1000 × 1 × 1
2.05 M
2.05 M
Total: 25,557,032 parameters (25.56 M), 4.09 G multiply–adds per image at 224 × 224.
ResNet-5025.56 M parameters4.09 G MACs
ResNeXt-50 (32×4d)25.03 M parameters4.23 G MACs
Bars show each row's share of the total. Convolutions dominate compute because they run at every position; fully connected layers dominate parameters in older designs (AlexNet, VGG). Changing the input size changes the compute of every convolution but not its parameters. Parameter counts include biases and BatchNorm scale and shift and match torchvision's implementations.
Why engineers care

ConvNeXt shows that well-designed convolutional networks remain competitive, and they are often easier to deploy on embedded hardware than transformers, with no attention layers and good support for any input size, for robots, drones and satellites.

📝 Quick check (Level 0)
0/3 answered
  1. 1. ConvNeXt is…
  2. 2. It started from…
  3. 3. Its final accuracy compared with Swin-T was…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

The roadmap from ResNet-50 at about 4.5 G FLOPs:

  1. Modern training recipe: 76.1% → 78.8%.
  2. Stage ratio 3:4:6:3 → 3:3:9:3.
  3. Patchify stem: a 4 × 4 stride-4 convolution, so 224 → 56 at once.
  4. ResNeXt-ify: depthwise 3 × 3 convolutions, width raised to 96.
  5. Inverted bottleneck (C → 4C → C).
  6. Move the depthwise convolution to the top of the block and enlarge it to 7 × 7.
  7. Micro changes:
    • GELU;
    • one activation and one normalisation per block;
    • BN → LayerNorm;
    • separate 2 × 2 stride-2 downsampling layers.

The result is 82.0%.

Block: x + γ·W₂ GELU(W₁ LN(DW₇ₓ₇(x))), where γ is a learned per-channel layer scale initialised to 10⁻⁶.

Costs:

  • A ConvNeXt-T block at C = 96 has 79,296 parameters, of which the 7 × 7 depthwise holds 4,704 (6%).
  • A dense 3 × 3 at 96 channels would need 82,944 weights for the filter alone.
  • ConvNeXt-T has 28.6 M parameters and 4.46 G multiply–adds, against ResNet-50’s 25.6 M and 4.09 G.
📝 Quick check (Level 1)
0/3 answered
  1. 1. ConvNeXt-T's stage ratio:
  2. 2. The patchify stem is…
  3. 3. Layer scale γ is initialised to…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

ConvNeXt in code

Exercise 1.

  • The ConvNeXt block kept its input shape.
  • With layer scale 10⁻⁶ it was almost exactly the identity.
  • LayerNorm normalised each pixel’s channels to mean 0 and standard deviation 1.
  • GELU matched its known values.

Practice.

  • torchvision has convnext_tiny/small/base/large.
  • Training recipe:
    • AdamW, 300 epochs, learning rate 4·10⁻³ for batch 4,096, cosine schedule;
    • weight decay 0.05;
    • Mixup, CutMix, RandAugment, Random Erasing, label smoothing and stochastic depth;
    • an EMA of the weights.
  • Much of the gain over the original ResNet comes from this recipe (76.1% → 78.8% before any design change).
  • ConvNeXt V2 (2023) added masked-autoencoder pretraining and global response normalisation.
model = torchvision.models.convnext_tiny(weights="IMAGENET1K_V1")    # 28.6 M parameters
🐍 Exercise 1: a ConvNeXt block
Implement GELU, channel LayerNorm, a same-padded depthwise convolution and the ConvNeXt block.
📝 Quick check (Level 2)
0/3 answered
  1. 1. ConvNeXt's optimiser:
  2. 2. The modern recipe alone moved ResNet-50 from 76.1% to…
  3. 3. ConvNeXt V2 added…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

Separating design from training. Comparing a 2015 ResNet with a 2021 transformer mixes two changes: architecture and training recipe. ConvNeXt changed one thing at a time and measured each, which attributes the gap fairly. Roughly 2.7 points came from the recipe and 3.2 from design.

Which transformer ideas carried over.

  • Patchify stem and stage ratio: follow Swin.
  • Depthwise convolution: analogous to the per-channel spatial mixing of self-attention.
  • Inverted bottleneck: like a transformer’s MLP with expansion 4.
  • Large kernels: like attention’s large windows. Gains saturated at 7 × 7.
  • One activation and one norm per block, LayerNorm and GELU: as in transformer blocks.

Why large kernels are cheap here. Depthwise k × k costs k²·C weights per block, against 8C² for the two 1 × 1 layers. At C = 96, going from 3 × 3 to 7 × 7 adds 40·96 = 3,840 weights per block, about 5% of the block, and under 1% of the network (exercise 2).

Limits.

  • Convolutions still lack attention’s input-dependent weighting.
  • ConvNeXt’s advantage depends on the heavy modern recipe.
  • Depthwise 7 × 7 convolutions are memory-bound on some hardware.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Depthwise convolution is analogous to…
  2. 2. Kernel-size gains saturated at…
  3. 3. The inverted bottleneck mirrors…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

What do the large kernels cost?

History.

  • Z. Liu, H. Mao, C.-Y. Wu, C. Feichtenhofer, T. Darrell and S. Xie (2022) introduced ConvNeXt at CVPR (“A ConvNet for the 2020s”).
  • Z. Liu et al. (2021) introduced the Swin Transformer, ConvNeXt’s main comparison.
  • S. Woo et al. (2023) introduced ConvNeXt V2.

Exercise 2. This is a calculation, not a training run. It counts ConvNeXt-T’s parameters and multiply–adds layer by layer and checks them against torchvision. It then repeats the count with 3 × 3 and 11 × 11 depthwise kernels, and compares with ResNet-50:

model parameters multiply–adds (G)
ConvNeXt-T, 7 × 7 28,589,128 4.46
ConvNeXt-T, 3 × 3 28,324,168 4.37
ConvNeXt-T, 11 × 11 29,066,056 4.61
ResNet-50 25,557,032 4.09
  • The count matches torchvision exactly.
  • Large kernels are nearly free: 7 × 7 instead of 3 × 3 adds 264,960 parameters (0.9%) and 2.0% compute. Almost all of the cost is in the 1 × 1 layers.
  • ConvNeXt-T is close to ResNet-50 in cost (12% more parameters, 9% more compute), yet 3.2 points more accurate with the same training recipe (82.0% against 78.8%, the paper’s figures). Accuracy is not computed here.
🐍 Exercise 2 (research): what do the large kernels cost?
Count ConvNeXt-T's parameters and multiply–adds, check them against torchvision, and vary the depthwise kernel size.

ConvNeXt in AI, robotics and aerospace

  • Backbones for dense prediction: ConvNeXt backbones are common in detection and segmentation (with UperNet or Mask R-CNN), including for aerial and satellite imagery.
  • Deployment: a purely convolutional design runs on accelerators and runtimes that lack efficient attention, and handles variable input sizes naturally.
  • Lesson: compare architectures with equal training recipes before drawing conclusions.

References

  1. Z. Liu, H. Mao, C.-Y. Wu, C. Feichtenhofer, T. Darrell, S. Xie (2022). “A ConvNet for the 2020s.” Proc. CVPR.
  2. Z. Liu et al. (2021). “Swin Transformer: hierarchical vision transformer using shifted windows.” Proc. ICCV.
  3. S. Woo et al. (2023). “ConvNeXt V2: co-designing and scaling ConvNets with masked autoencoders.” Proc. CVPR.