3 个月前

CvT:将卷积引入视觉Transformer

CvT:将卷积引入视觉Transformer

摘要

本文提出了一种名为卷积视觉Transformer(Convolutional Vision Transformer, CvT)的新架构,通过在视觉Transformer(Vision Transformer, ViT)中引入卷积操作,有效提升了模型在性能与效率方面的表现,实现了两种设计的优势融合。这一改进主要通过两项关键设计实现:其一,构建了包含新型卷积令牌嵌入(convolutional token embedding)的分层Transformer结构;其二,提出了一种基于卷积投影的卷积Transformer模块(convolutional Transformer block)。这些改进将卷积神经网络(CNN)所具备的优良特性(如平移、缩放与形变不变性)引入ViT架构,同时保留了Transformer的核心优势(如动态注意力机制、全局上下文建模能力以及更强的泛化性能)。我们通过大量实验验证了CvT的有效性,结果表明,相较于其他Vision Transformer及ResNet系列模型,CvT在ImageNet-1k数据集上达到了当前最优的性能表现,同时参数量更少、浮点运算量(FLOPs)更低。此外,在更大规模数据集(如ImageNet-22k)上预训练后,模型在下游任务上的微调性能依然保持显著优势。具体而言,基于ImageNet-22k预训练的CvT-W24在ImageNet-1k验证集上取得了87.7%的Top-1准确率。最后,我们的研究发现,在CvT模型中,现有Vision Transformer中至关重要的位置编码(positional encoding)可以被安全移除,从而简化模型结构,尤其有利于高分辨率视觉任务的设计。相关代码将开源发布于:https://github.com/leoxiaobin/CvT。

代码仓库

leoxiaobin/CvT
pytorch
GitHub 中提及
conceptofmind/CvT-flax
jax
GitHub 中提及
ttt496/vit-pytorch
pytorch
GitHub 中提及
BR-IDL/PaddleViT
paddle
GitHub 中提及
microsoft/CvT
官方
pytorch
GitHub 中提及
EMalagoli92/CvT-TensorFlow
tf
GitHub 中提及
huggingface/transformers
pytorch
GitHub 中提及
SforAiDl/vformer
pytorch
GitHub 中提及
ahmedelmahy/myownvit
pytorch
GitHub 中提及

基准测试

基准方法指标
image-classification-on-cifar-10CvT-W24
Percentage correct: 99.39
image-classification-on-cifar-100CvT-W24
Percentage correct: 94.09
image-classification-on-flowers-102CvT-W24
Accuracy: 99.72
image-classification-on-imagenetCvT-13 (384 res)
GFLOPs: 16.3
Number of params: 20M
Top 1 Accuracy: 83%
image-classification-on-imagenetCvT-21 (384 res, ImageNet-22k pretrain)
GFLOPs: 25
Number of params: 32M
Top 1 Accuracy: 84.9%
image-classification-on-imagenetCvT-13
GFLOPs: 4.5
Top 1 Accuracy: 81.6%
image-classification-on-imagenetCvT-13-NAS
GFLOPs: 4.1
Number of params: 18M
Top 1 Accuracy: 82.2%
image-classification-on-imagenetCvT-W24 (384 res, ImageNet-22k pretrain)
Top 1 Accuracy: 87.7%
image-classification-on-imagenetCvT-21 (384 res)
GFLOPs: 24.9
Top 1 Accuracy: 83.3%
image-classification-on-imagenetCvT-21
GFLOPs: 7.1
Top 1 Accuracy: 82.5%
image-classification-on-imagenet-realCvT-W24 (384 res, ImageNet-22k pretrain)
Accuracy: 90.6%
Number of params: 277M
Top 1 Accuracy: 87.7%
image-classification-on-oxford-iiit-pets-1CvT-W24
Accuracy: 94.73

用 AI 构建 AI

从想法到上线——通过免费 AI 协同编程、开箱即用的环境和市场最优价格的 GPU 加速您的 AI 开发

AI 协同编程
即用型 GPU
最优价格
立即开始

Hyper Newsletters

订阅我们的最新资讯
我们会在北京时间 每周一的上午九点 向您的邮箱投递本周内的最新更新
邮件发送服务由 MailChimp 提供
CvT:将卷积引入视觉Transformer | 论文 | HyperAI超神经