Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

CvT: Introducing Convolutions to Vision Transformers

Convolutions added to Vision Transformers improve accuracy and efficiency

  • Problem Plain Vision Transformers trail similarly sized CNNs such as ResNets when trained on smaller datasets. They lack the local image structure that convolutions build into CNNs.
  • Method CvT adds a convolutional token embedding at the start of three stages. Unlike ViT's linear projections, it replaces each attention block's projections with depth-wise separable convolutions and drops positional embedding.
  • Results CvT-W24, pretrained on ImageNet-22k, reaches 87.7% top-1 on the ImageNet-1k validation set.

Why plain ViT trails CNNs

Vision Transformer (ViT) turns an image into non-overlapping patch tokens, adds a positional encoding to them, and runs standard Transformer layers over the sequence. At large scale this recipe is competitive, but on smaller training sets ViT trails similarly sized convolutional networks such as ResNets. The authors suspect the gap comes from properties that CNNs build in and ViT does not.

Images have strong two-dimensional local structure, since neighboring pixels are highly correlated, and CNNs exploit this with local receptive fields, shared weights and spatial subsampling. The authors hypothesize that convolutions can be introduced into ViT to improve performance and robustness without giving up computational and memory efficiency.

Convolutional token embedding

The first change is a Convolutional Token Embedding placed at the start of every stage. Its input is the flattened token sequence reshaped back onto its spatial grid, so the convolution operates on a two-dimensional map rather than on a list of tokens. For a stage input \(x_{i-1}\) of size \(H_{i-1}\times W_{i-1}\times C_{i-1}\), the layer is a 2D convolution with kernel size \(s\times s\), stride \(s-o\) and padding \(p\).

\[ H_i=\left\lfloor \frac{H_{i-1}+2p-s}{s-o+1}\right\rfloor \] gives the output height, and the width follows the same form. The output map is flattened to \(H_iW_i\) tokens of width \(C_i\) and normalized by layer normalization before the stage's Transformer blocks.

Kernel size, stride, padding and output channels are free settings, so each stage can set its own token count and feature width, with the token sequence shrinking while the features widen, as in CNN feature hierarchies. In CvT-13 the first stage uses a 7×7 kernel with stride 4 and 64 channels, and the second and third stages use 3×3 kernels with stride 2 and 192 and 384 channels.

Because the kernel is larger than the stride, neighboring patches overlap, unlike the non-overlapping patch split of ViT.

Convolutional projection in attention

Inside each attention block, the linear projection that forms queries, keys and values is replaced by a convolution over the reshaped token map. The tokens are reshaped to 2D, passed through a depth-wise convolution, then BatchNorm2d, then a point-wise convolution, and flattened back to a one-dimensional sequence. \[ x^{q/k/v}_i=\mathrm{Flatten}\big(\mathrm{Conv2d}(\mathrm{Reshape2D}(x_i),\,s)\big) \] Here \(x_i\) is the token input before the projection, \(s\) is the kernel size, and the output is the query, key or value input at that layer.

A standard \(s\times s\) convolution in this position would need \(s^2C^2\) parameters and \(O(s^2C^2T)\) FLOPs, where \(C\) is the token channel dimension and \(T\) the number of tokens. The depth-wise separable form adds only \(s^2C\) parameters and \(O(s^2CT)\) FLOPs over the original linear projection. The original position-wise linear projection is itself a convolution with a \(1\times1\) kernel, so the change widens the same operation rather than adding a new stage.

The second saving comes from stride: the query keeps stride 1, while key and value use stride 2. Subsampling keys and values this way cuts their token count four times and cuts the cost of the later attention computation by four times. The authors expect little loss from this, since neighboring pixels and patches are redundant in appearance and semantics, and the local context from the convolution compensates for the lost resolution.

Stage layout and block structure

CvT arranges its blocks in three stages, each starting with a convolutional token embedding and followed by a stack of Convolutional Transformer Blocks. Each block applies convolutional projection first, then multi-head self-attention and an MLP. Positional embedding is not summed into the tokens.

A classification token is added only in the last stage, and an MLP head on that token predicts the class. CvT-13, CvT-21 and CvT-W24 differ in block count per stage: 1, 2 and 10 for CvT-13, 1, 4 and 16 for CvT-21, and 2, 2 and 20 for CvT-W24.

The size of the wide model is given in two ways: the model variants text says 298.3M parameters, while Table 2 lists 276.7 M and Table 3 lists 277 M for CvT-W24. The 298.3M value does not match either table.

Training and fine-tuning settings

ImageNet-1k has about 1.3M images in 1k classes, and ImageNet-22k has 14M images in 22k classes. Downstream transfer uses CIFAR-10, CIFAR-100, Oxford-IIIT Pet and Oxford-IIIT Flower after pretraining on ImageNet-22k.

ImageNet training uses AdamW, with weight decay 0.05 for CvT-13 and 0.1 for CvT-21 and CvT-W24. The learning rate starts at 0.02 with cosine decay, the total batch size is 2048, and training runs for 300 epochs with the augmentation and regularization of ViT. Models train at 224×224 input unless stated otherwise.

Fine-tuning uses SGD with momentum 0.9, pretrains at 224×224 and fine-tunes at 384×384.

The searched CvT-13-NAS variant

CvT-13-NAS comes from a search over the stride (1 or 2) of the key and value projections and the MLP expansion ratio (2 or 4). The searched model uses stride 2 and MLP ratio 2 at the first and last stages, and stride 1 with MLP ratio 4 in most layers of the middle stage.

ImageNet-22k pretraining results

Pretraining on ImageNet-22k and fine-tuning at 384×384 brings CvT-W24 to 87.7% top-1 on ImageNet-1k.

The ViT and BiT rows in these 22k groups come from their own works, while the CvT rows are fine-tuned at 384 input.

Downstream transfer results

Table 4 transfers ImageNet-22k pretrained models to CIFAR10, CIFAR100, Pets and Flowers102. CvT-W24 scored 99.39, 94.09, 94.73 and 99.72 on those four datasets. It has the top score on CIFAR10, CIFAR100 and Flowers102, and ties ViT-L/16 on Pets at 94.73, so the prose's claim of best performance on all downstream tasks holds only with that tie.

The smaller models score lower in places: CvT-13 reached 98.83 on CIFAR10 and 91.11 on CIFAR100, below ViT-B/16 at 98.95 and 91.67. CvT-21 reached 92.88 on CIFAR100 and 94.03 on Pets.

Positional embedding ablation

Removing positional embedding from DeiT-S lowers its ImageNet top-1 from 79.8 to 78.0. CvT-13 reaches 81.5 with positional embedding in every stage, 81.4 with it in the first stage only, 81.4 in the last stage only, and 81.6 with none. The authors read this as CvT not needing a positional embedding, and read the DeiT-S drop as showing that DeiT does not model spatial relations beyond adding the embedding.

The authors also argue that fixed-length learned position vectors restrict variable-length input, and that CvT could handle variable image resolutions without redesigning the embedding. The reported experiments use 224×224 input for pretraining and 384×384 for fine-tuning, so the variable-resolution benefit is argued rather than tested.

Token embedding ablation

Table 6 compares non-overlapping patch embedding with the Convolutional Token Embedding, with and without position embedding. The prose gives a 0.8% drop for that replacement, while the table entries are 80.7 and 81.6.

With position embedding in use, adding the Convolutional Token Embedding moves the score from 81.1 to 81.4. The prose calls this a 0.3% gain. The prose also describes a 0.1% drop when both components are used, while the table gives 81.4 for that combination and 81.6 for CvT-13 without position embedding.

The authors take these results to show that the token embedding improves accuracy and lets CvT model spatial relations without a positional embedding.

Projection stride and stage ablations

The authors keep stride 2 as the default for lower computation and memory use.

Table 8 switches convolutional projection on stage by stage: none gives 80.6, stage 1 only gives 80.8, stages 1 and 2 give 81.0, and all three stages give 81.6. Block counts per stage are 1, 2 and 10. The prose gives the improvement as from 80.6% to 81.5%, whereas the table's all-stage row is 81.6. The authors read the steady rise as support for the design, since accuracy improves each time another stage adopts it.

Limitations

Experiments cover ImageNet-1k, ImageNet-22k pretraining and four downstream datasets: CIFAR-10, CIFAR-100, Oxford-IIIT Pets and Oxford-IIIT Flowers-102. The NAS search is evaluated only on ImageNet-1k. The ablation tables give one top-1 value per variant, and no variance is reported.

The wide model's parameter count is 298.3M in the prose, 276.7M in Table 2 and 277M in Table 3. Several prose margins differ from table values: the DeiT-B margin, the stride-2 drop and the all-stage endpoint in the stage ablation.

Paper info

Authors
Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, Lei Zhang
Venue
arXiv · Preprint
First published
2021-3-29
Added
2026-11-12
Updated
2021-3-29
Version
v1
arXiv
2103.15808
Category
cs.CV
Original paper terms
CC BY 4.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, Lei Zhang (2021). CvT: Introducing Convolutions to Vision Transformers. arXiv:2103.15808v1. https://arxiv.org/abs/2103.15808v1

BibTeX
@misc{wu2021introducing,
  title = {{CvT: Introducing Convolutions to Vision Transformers}},
  author = {Haiping Wu and Bin Xiao and Noel Codella and Mengchen Liu and Xiyang Dai and Lu Yuan and Lei Zhang},
  year = {2021},
  eprint = {2103.15808},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.15808v1}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up