HackerPapers

arXiv:2103.15808cs.CV

CvT: Introducing Convolutions to Vision Transformers

Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, Lei Zhang

Abstract

We present in this paper a new architecture, named Convolutional vision Transformer (CvT), that improves Vision Transformer (ViT) in performance and efficiency by introducing convolutions into ViT to yield the best of both designs. This is accomplished through two primary modifications: a hierarchy of Transformers containing a new convolutional token embedding, and a convolutional Transformer block leveraging a convolutional projection. These changes introduce desirable properties of convolutional neural networks (CNNs) to the ViT architecture (\ie shift, scale, and distortion invariance) while maintaining the merits of Transformers (\ie dynamic attention, global context, and better generalization). We validate CvT by conducting extensive experiments, showing that this approach achieves state-of-the-art performance over other Vision Transformers and ResNets on ImageNet-1k, with fewer parameters and lower FLOPs. In addition, performance gains are maintained when pretrained on larger datasets (\eg ImageNet-22k) and fine-tuned to downstream tasks. Pre-trained on ImageNet-22k, our CvT-W24 obtains a top-1 accuracy of 87.7\% on the ImageNet-1k val set. Finally, our results show that the positional encoding, a crucial component in existing Vision Transformers, can be safely removed in our model, simplifying the design for higher resolution vision tasks. Code will be released at \url{https://github.com/leoxiaobin/CvT}.

arXiv comments
Journal reference
DOI
Subjects
cs.CVComputer Vision and Pattern Recognition

On Hacker News

Linked by 3 identifiable commenters in 3 comments across 3 threads, from Mar 2022 to Dec 2025.

Comments linking this paper, per year.

Discussed in comments3 threads

  1. The Illustrated Transformer 1 comment
    • Indeed, there are even multiple attempts to use both self-attention and convolutions in novel architectures, and there is evidence this works very well and may have significant advantages over pure vision transformer models [1-2]. IMO there is little reason to think transformers…

      D-MachineView on HNParent context

  2. [dead] 1 comment
    • An open-source implementation of the CvT: Introducing Convolutions to Vision Transformers research paper in Google's JAX and Flax. JAX/Flax Repository: https://github.com/conceptofmind/CvT-flax CvT Research Paper: https://arxiv.org/abs/2103.15808 Official Github Repository…

      EnricoShippoleView on HNParent context

    • Good point. The fact there is no inductive bias inherent to transformers makes it difficult to train a decent model on small datasets from scratch. However, there are recent research directions that try to address this problem [1]. Also baking in some sort of domain specific…

      tourist_on_roadView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.