↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Stage 4 · block 1 of 3 7 × 7 tokens · no queries, keys or softmax · 768 channels, each with its own 7 × 7 kernel and bias · the same fixed matrices for every image
Loading recorded convolution…

What ConvNeXt is

By 2021 vision Transformers had overtaken convolutional networks, and the hierarchical ones, Swin above all, had done so partly by bringing convolutional ideas back: local windows, and stages that halve the resolution. Liu et al. (2022) asked how much of the gap came from attention itself. They took a ResNet and changed it one design choice at a time towards a Swin Transformer, keeping it a pure convolutional network. The result, ConvNeXt, competes with Transformers in accuracy and scaling; the abstract reports 87.8 % ImageNet top-1 and better COCO detection and ADE20K segmentation than Swin.

The page records ConvNeXt-T, the smallest of the paper's main models, in its last stage: three blocks on a 7 × 7 grid of tokens 32 pixels square, with 768 channels. Its top-1 guesses are Egyptian cat (89 %), beagle (91 %), space shuttle (99 %, for the astronaut) and ping-pong ball (30 %, for the coloured shapes).

From ResNet to ConvNeXt

The paper's steps, each kept because it helped:

  • Macro design: blocks per stage in Swin's 1 : 1 : 3 : 1 ratio, 3, 3, 9 and 3 for ConvNeXt-T, and a patchify stem, a 4 × 4 convolution with stride 4, like a ViT's patch embedding.
  • Depthwise convolution: spatial mixing done separately for each channel, with channel mixing left to 1 × 1 layers, much as attention mixes positions and the MLP mixes channels.
  • Inverted bottleneck: the MLP widens the channels 4 times and narrows them back, like a Transformer's.
  • Large kernel: the depthwise convolution moves to the top of the block and grows to 7 × 7, the size of Swin's attention windows.
  • Micro design: GELU instead of ReLU, fewer activations and normalisations, LayerNorm instead of BatchNorm, and separate downsampling layers between stages.

The block

Each ConvNeXt block computes

widens 768 channels to 3,072 and narrows them back, both applied to each token separately, and is a per-channel layer scale. The depthwise convolution comes first, with no norm before it, and it is the only place where tokens exchange information. The page's columns follow it: Block input, Depthwise 7 × 7 conv, and Conv output, which then goes through the LayerNorm, the 4× MLP and into the residual.

A depthwise convolution as 49 × 49 matrices

For channel with kernel and bias , the token at row and column of the grid gets

summed over the tokens within 3 rows and 3 columns of ; the kernel's other taps fall on zero padding. On the 7 × 7 grid that is one 49 × 49 matrix per channel, the same for every image, and channels never mix in it. The Depthwise 7 × 7 conv card draws it for the first 16 of the 768 channels, the channel's kernel is drawn beside the image, and the selected token's window is marked on the image: the centre token reads all 49 tokens, a corner token only 16. The note and the popup check that the row, times the input, plus the bias, gives the recorded output.

Convolution and attention

A depthwise convolution and local attention both compute, for each position and channel, a weighted sum over a window of neighbours. They differ in where the weights come from. The convolution's are learned once, per channel and per offset, and are the same for every input; attention's are computed from the input at every position and shared by the channels of a head. Han et al. (2021) made the comparison explicit and found that depthwise convolution, and a dynamic variant whose kernels are predicted from the input, perform on par with or slightly better than local attention in Swin-like networks.

Across this group of tabs the mixing weights range from fixed and shared by all channels (PoolFormer), through fixed per channel (ConvNeXt, and the Conformer's convolution module), to dependent on the input through a non-linearity (Mixer) and fully content-based (attention).

Where it came from

ResNet (2015) made deep convolutional networks trainable with residual connections. MobileNets and Xception (2017) split convolutions into depthwise and pointwise parts to cut their cost. Swin (2021) restricted attention to shifted local windows. ConvNeXt combined the lessons, and ConvNeXt V2 (2023) added masked-autoencoder pre-training and a global response normalisation layer. PoolFormer (the PoolFormer tab) arrives at a similar block from the other side, by simplifying a Transformer's token mixer.

Papers

  1. A ConvNet for the 2020s Zhuang Liu, Hanzi Mao, Chao-Yuan Wu, Christoph Feichtenhofer, Trevor Darrell, Saining Xie · CVPR 2022 ConvNeXt: a ResNet modernised step by step towards Swin, with a depthwise 7 × 7 convolution as its token mixer.
  2. Swin Transformer: Hierarchical Vision Transformer using Shifted Windows Ze Liu et al. · ICCV 2021 The hierarchical vision Transformer with local windows that ConvNeXt's design follows.
  3. Deep Residual Learning for Image Recognition Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun · CVPR 2016 ResNet, the starting point of ConvNeXt's modernisation.
  4. Xception: Deep Learning with Depthwise Separable Convolutions François Chollet · CVPR 2017 Depthwise separable convolutions throughout a deep network: spatial and channel mixing done apart.
  5. MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications Andrew G. Howard et al. · arXiv 2017 Depthwise and pointwise convolutions to cut the cost of convolutional networks.
  6. On the Connection between Local Attention and Dynamic Depth-wise Convolution Qi Han et al. · ICLR 2022 Local attention and depthwise convolution compared as the same kind of windowed weighted sum.
  7. ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders Sanghyun Woo et al. · CVPR 2023 ConvNeXt with masked-autoencoder pre-training and global response normalisation.

See also