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

CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification

Cross-attention lets two transformer branches exchange multi-scale image features

  • Problem Vision Transformers face a trade-off between patch size and cost: finer patches improve accuracy but raise FLOPs sharply. Single-scale token sets cannot use both scales at once, and naive fusion of all tokens grows quadratically.
  • Method CrossViT runs a large-patch branch and a small-patch branch in parallel. Each branch's CLS token alone queries the other branch's tokens through cross-attention, which keeps the cost linear.
  • Results CrossViT-18 scored 91.36 on CIFAR100 in transfer learning, on par with DeiT-S at 90.89. The authors report 2% gain over DeiT on ImageNet1K.

Why patch size is a trade-off

A Vision Transformer cuts an image into patches, projects each patch into a token, and then runs self-attention over the token sequence, so the patch size fixes how fine the representation is. Finer patches improve accuracy, but the cost rises quickly: the authors report that a patch size of 16 beats a patch size of 32 by 6%, while the finer setting needs 4 times more FLOPs.

Multi-scale features have helped convolutional networks in tasks such as detection and efficient inference, for example in Big-Little Net and Octave convolutions, yet their use in vision transformers was largely unexplored at the time.

The study therefore asks whether tokens from two patch sizes, handled by two branches of different cost, can be fused several times inside a transformer to give better classification features. The fusion step is the part that has to stay cheap, because a naive join of all tokens makes the attention cost grow quadratically with the token count.

Two branches and their stacking

CrossViT is a stack of K multi-scale transformer encoders, and each of these encoders contains an L-branch and an S-branch. The L-branch uses the coarse patch size Pl with more transformer encoders and wider embeddings, while the S-branch uses the fine patch size Ps with fewer encoders and narrower embeddings, where Ps is smaller than Pl.

For the CrossViT-S configuration the small patch is 12, the large patch is 16, the embedding dimensions are 192 and 384, and K is 3 with N, M and L equal to 1, 4 and 1.

Each branch receives its own CLS token, and position embeddings are added to every token, including the CLS token, before the first multi-scale encoder. At the end the two CLS tokens are combined and passed to the classification head, so the prediction uses one summary per branch. The depth is set by the branch sizes: CrossViT-15 has 3 multi-scale encoders with 5 regular transformer encoders each, giving 15 encoders in the large branch.

How cross-attention moves information between branches

The procedure is written for the L-branch and is repeated for the S-branch with the two indices swapped. The L-branch first projects its own CLS token with a projection f, concatenates it with the patch tokens of the S-branch, and gets the input for the attention step. \\(x'^{l} = [\\, f^{l}(x^{l}_{cls}) \\,\\|\\, x^{s}_{patch}\\,]\\)

Only the projected CLS token is used as the query, so the attention map has one row per head and its cost is linear in the number of tokens rather than quadratic. \\(q = x'^{l}_{cls} W_q,\\; k = x'^{l} W_k,\\; v = x'^{l} W_v\\), with \\(W_q, W_k, W_v\\) learnable and of size \\(C \\times (C/h)\\), where C is the embedding dimension and h the number of heads.

\\(A = \\mathrm{softmax}(q k^{T} / \\sqrt{C/h})\\) and \\(CA(x'^{l}) = A v\\), and multiple heads are used in the same way as in self-attention.

The attended output is added back to the projected CLS token with layer normalization applied to the concatenated input, and the result is projected back into the branch's own dimension. \\(y^{l}_{cls} = f^{l}(x^{l}_{cls}) + MCA(LN([f^{l}(x^{l}_{cls}) \\| x^{s}_{patch}]))\\), and \\(z^{l} = [g^{l}(y^{l}_{cls}) \\| x^{l}_{patch}]\\), where f and g are the projection and back-projection functions.

No feed-forward network follows this cross-attention step, so the L-branch patch tokens pass through unchanged and only the CLS token carries the cross-scale information.

The CLS token already summarises the patches of its own branch, so letting it look at the patches of the other branch brings in information from a second scale. In the next encoder the same CLS token attends to its own patches again, which is how the cross-scale information reaches the patch tokens of its own branch.

Alternatives to cross-attention

The simplest option, all-attention fusion, concatenates the tokens of both branches and applies self-attention to all of them, which costs quadratic time in the total token count. Class token fusion sums the two CLS tokens, passes the sum back through a projection to each branch, and keeps the patch tokens unchanged, so only one token is processed.

Pairwise fusion interpolates the patch tokens of the two branches to a common spatial size and fuses them position by position, while the CLS tokens are summed separately.

Cross-attention keeps the efficiency of class token fusion, since only one token per branch acts as the query, but it still lets each branch read the other branch's patch tokens. The later ablation checks whether this design choice gives better accuracy than the three simpler schemes on CrossViT-S.

Training and evaluation setup

The main evaluation uses ImageNet1K, which has 1,000 classes and about 1.28 million training images, with top-1 accuracy on the 50,000-image validation set as the metric. The models follow the DeiT recipe, which trains a ViT on ImageNet alone with strong data augmentation and regularization, and the authors use DeiT's default hyperparameters.

Instance repetition is enabled only for CrossViT-18, because the authors found it did not help the smaller models.

At evaluation the shorter image side is resized to 256 and a 224 by 224 center crop is used, and some models were fine-tuned at 384 by 384 with bicubic resizing of the position embedding. A convolutional patch tokenizer replaces the linear projection in the variants marked with a dagger, and it is used as a hybrid option in the comparison tables.

Gains over the DeiT baselines

When DeiT-Ti, DeiT-S and DeiT-B serve as the large branch, CrossViT improves top-1 accuracy by 1.2, 1.2 and 0.4 points respectively, which the authors take as evidence that cross-attention learns useful multi-scale features. CrossViT-Ti reaches 73.4 against 72.2 for DeiT-Ti, CrossViT-S reaches 81.0 against 79.8 for DeiT-S, and CrossViT-B reaches 82.2 against 81.8 for DeiT-B, with FLOPs rising from 4.6 G to 5.6 G for the S pair.

The architectural changes described in Table 1 add a further 0.3 to 0.5 points, at a small cost in FLOPs and parameters.

The convolutional patch tokenizer adds 3.2 points to CrossViT-9, rising from 73.9 to 77.1, and 0.8 points to CrossViT-15.

The efficiency cost is visible in throughput, where CrossViT-S runs at 690 images per second and DeiT-S at 966 images per second in the same table.

Comparison with other transformers and CNNs

Against ViT-B at 384, CrossViT-18 with the convolutional tokenizer reaches 82.8 against 77.9, with 9.5 G against 17.6 G FLOPs, which is a 4.9 point difference in top-1 accuracy.

Against the CNN models in Table 4, CrossViT-15 reaches 81.5 at 640 images per second, faster than most of the listed CNNs except ResNet-101, which the authors note is slightly faster. At higher resolution, CrossViT-18 with the convolutional tokenizer at 480 reaches 84.1, and the authors describe the best CrossViT models as competitive with EfficientNet, while expecting neural architecture search to close the rest of the gap.

Transfer to smaller datasets

Transfer is tested on five tasks, CIFAR10, CIFAR100, Pet, CropDiseases and ChestXRay8, where the first four are natural images and ChestXRay8 contains medical images. The whole pretrained model is fine-tuned for 1,000 epochs with batch size 768, learning rate 0.01, SGD, weight decay 0.0001 and the ImageNet1K augmentation.

CrossViT-18 scores 99.11 on CIFAR10, 91.36 on CIFAR100, 95.07 on Pet, 99.97 on CropDiseases and 55.94 on ChestXRay8. DeiT-S scores 99.15, 90.89, 94.93, 99.96 and 55.39 on the same tasks, and CrossViT-15 scores 99.00, 90.77, 94.55, 99.97 and 55.89. The authors describe their models as on par with the DeiT models on all five downstream tasks, although CrossViT-15 sits slightly below DeiT-S on CIFAR10 and CIFAR100.

What the ablations isolate

Cross-attention is the only scheme in which the S-branch reaches useful accuracy on its own, at 47.2 against 68.1 for the L-branch, while the other schemes leave the S-branch near chance at 0.1 to 7.6. The authors attribute this to the L-branch dominating in the other schemes, so that cross-attention is the only scheme in which the two branches learn distinct features whose ensemble is the best result.

Changing the small patch from 12 to 8 gives 80.8 with 6.7 G FLOPs, below the 81.0 at 5.6 G for the 12 and 16 pair, because the token ratio of 4 times is harder to fuse than a ratio of 2 times. The authors read these results as showing that the L-branch carries most of the feature extraction, so a light S-branch is enough, and that extra fusion steps add cost without accuracy.

Removing the CLS tokens and averaging the patch tokens of one branch as the query gives 80.0%, about 1% below the 81.0% of CrossViT-S, which supports the CLS token as the branch summary. Using the T2T module in place of the linear patch projection in both branches of CrossViT-18 gives 83.0% top-1, which is 0.5% above CrossViT-18 at 82.5.

Limitations

The fusion ablations are run only on CrossViT-S, so the relative order of the fusion schemes is shown for that one configuration. The comparison with EfficientNet uses the higher-resolution variants, and the authors state that the remaining gap is an open question that neural architecture search might close. Throughput numbers come from one GPU type and one batch size in the CNN table, and the comparison with other transformers uses accuracies from the models' original reports rather than re-training.

The transfer experiments fine-tune for 1,000 epochs on five tasks, and the paper does not report results on other downstream tasks. The transformer variants in the comparison were trained only on ImageNet1K, and the stated scope of the claims covers that setting.

Paper info

Authors
Chun-Fu Chen, Quanfu Fan, Rameswar Panda
Venue
arXiv · Preprint
First published
2021-3-27
Added
2026-11-12
Updated
2021-8-22
Version
v2
arXiv
2103.14899
Category
cs.CV
Original paper terms
CC BY-NC-SA 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

Chun-Fu Chen, Quanfu Fan, Rameswar Panda (2021). CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification. arXiv:2103.14899v2. https://arxiv.org/abs/2103.14899v2

BibTeX
@misc{chen2021crossvit,
  title = {{CrossViT: Cross-Attention Multi-Scale Vision Transformer for Image Classification}},
  author = {Chun-Fu Chen and Quanfu Fan and Rameswar Panda},
  year = {2021},
  eprint = {2103.14899},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.14899v2}
}

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