HyperAIHyperAI

Command Palette

Search for a command to run...

3 months ago

Incorporating Convolution Designs into Visual Transformers

Kun Yuan Shaopeng Guo Ziwei Liu Aojun Zhou Fengwei Yu Wei Wu

Incorporating Convolution Designs into Visual Transformers

Abstract

Motivated by the success of Transformers in natural language processing (NLP) tasks, there emerge some attempts (e.g., ViT and DeiT) to apply Transformers to the vision domain. However, pure Transformer architectures often require a large amount of training data or extra supervision to obtain comparable performance with convolutional neural networks (CNNs). To overcome these limitations, we analyze the potential drawbacks when directly borrowing Transformer architectures from NLP. Then we propose a new \textbf{Convolution-enhanced image Transformer (CeiT)} which combines the advantages of CNNs in extracting low-level features, strengthening locality, and the advantages of Transformers in establishing long-range dependencies. Three modifications are made to the original Transformer: \textbf{1)} instead of the straightforward tokenization from raw input images, we design an \textbf{Image-to-Tokens (I2T)} module that extracts patches from generated low-level features; \textbf{2)} the feed-froward network in each encoder block is replaced with a \textbf{Locally-enhanced Feed-Forward (LeFF)} layer that promotes the correlation among neighboring tokens in the spatial dimension; \textbf{3)} a \textbf{Layer-wise Class token Attention (LCA)} is attached at the top of the Transformer that utilizes the multi-level representations. Experimental results on ImageNet and seven downstream tasks show the effectiveness and generalization ability of CeiT compared with previous Transformers and state-of-the-art CNNs, without requiring a large amount of training data and extra CNN teachers. Besides, CeiT models also demonstrate better convergence with $3\times$ fewer training iterations, which can reduce the training cost significantly\footnote{Code and models will be released upon acceptance.}.

Code Repositories

Benchmarks

BenchmarkMethodologyMetrics
image-classification-on-cifar-10CeiT-S (384 finetune resolution)
Percentage correct: 99.1
image-classification-on-cifar-10CeiT-S
Percentage correct: 99
image-classification-on-cifar-10CeiT-T
Percentage correct: 98.5
image-classification-on-cifar-100CeiT-T
Percentage correct: 89.4
image-classification-on-cifar-100CeiT-S (384 finetune resolution)
Percentage correct: 91.8
image-classification-on-cifar-100CeiT-T (384 finetune resolution)
Percentage correct: 88
image-classification-on-cifar-100CeiT-S
Percentage correct: 91.8
image-classification-on-flowers-102CeiT-S (384 finetune resolution)
Accuracy: 98.6
image-classification-on-flowers-102CeiT-T
Accuracy: 96.9
image-classification-on-flowers-102CeiT-T (384 finetune resolution)
Accuracy: 97.8
image-classification-on-flowers-102CeiT-S
Accuracy: 98.2
image-classification-on-imagenetCeiT-T
GFLOPs: 1.2
Number of params: 6.4M
Top 1 Accuracy: 76.4%
image-classification-on-imagenetCeiT-S
GFLOPs: 4.5
Top 1 Accuracy: 82%
image-classification-on-imagenetCeiT-S (384 finetune res)
GFLOPs: 12.9
Number of params: 24.2M
Top 1 Accuracy: 83.3%
image-classification-on-imagenetCeiT-T (384 finetune res)
GFLOPs: 3.6
Top 1 Accuracy: 78.8%
image-classification-on-imagenet-realCeiT-T
Accuracy: 83.6%
image-classification-on-imagenet-realCeiT-S (384 finetune res)
Accuracy: 88.1%
image-classification-on-imagenet-realCeiT-S
Accuracy: 87.3%
image-classification-on-inaturalist-2018CeiT-T (384 finetune resolution)
Top-1 Accuracy: 72.2%
image-classification-on-inaturalist-2018CeiT-S (384 finetune resolution)
Top-1 Accuracy: 79.4%
image-classification-on-inaturalist-2018CeiT-T
Top-1 Accuracy: 64.3%
image-classification-on-inaturalist-2018CeiT-S
Top-1 Accuracy: 73.3%
image-classification-on-inaturalist-2019CeiT-S
Top-1 Accuracy: 78.9
image-classification-on-inaturalist-2019CeiT-S (384 finetune resolution)
Top-1 Accuracy: 82.7
image-classification-on-inaturalist-2019CeiT-T
Top-1 Accuracy: 72.8
image-classification-on-inaturalist-2019CeiT-T (384 finetune resolution)
Top-1 Accuracy: 77.9
image-classification-on-oxford-iiit-pets-1CeiT-T (384 finetune resolution)
Accuracy: 94.5
image-classification-on-oxford-iiit-pets-1CeiT-T
Accuracy: 93.8
image-classification-on-oxford-iiit-pets-1CeiT-S
Accuracy: 94.6
image-classification-on-oxford-iiit-pets-1CeiT-S (384 finetune resolution)
Accuracy: 94.9
image-classification-on-stanford-carsCeiT-S
Accuracy: 93.2
image-classification-on-stanford-carsCeiT-S (384 finetune resolution)
Accuracy: 94.1
image-classification-on-stanford-carsCeiT-T
Accuracy: 90.5
image-classification-on-stanford-carsCeiT-T (384 finetune resolution)
Accuracy: 93

Build AI with AI

From idea to launch — accelerate your AI development with free AI co-coding, out-of-the-box environment and best price of GPUs.

AI Co-coding
Ready-to-use GPUs
Best Pricing
Get Started

Hyper Newsletters

Subscribe to our latest updates
We will deliver the latest updates of the week to your inbox at nine o'clock every Monday morning
Powered by MailChimp