Papers › Not All Images are Worth 16x16 Words: Dynamic Transformers for Efficient Image Recognition

Not All Images are Worth 16x16 Words: Dynamic Transformers for Efficient Image Recognition

31 May 2021NeurIPS 2021 12arXiv:2105.15075archive 2025-07-28

Yulin Wang, Rui Huang, Shiji Song, Zeyi Huang, Gao Huang

Vision Transformers (ViT) have achieved remarkable success in large-scale image recognition. They split every 2D image into a fixed number of patches, each of which is treated as a token. Generally, representing an image with more tokens would lead to higher prediction accuracy, while it also results in drastically increased computational cost. To achieve a decent trade-off between accuracy and speed, the number of tokens is empirically set to 16x16 or 14x14. In this paper, we argue that every image has its own characteristics, and ideally the token number should be conditioned on each individual input. In fact, we have observed that there exist a considerable number of "easy" images which can be accurately predicted with a mere number of 4x4 tokens, while only a small fraction of "hard" ones need a finer representation. Inspired by this phenomenon, we propose a Dynamic Transformer to automatically configure a proper number of tokens for each input image. This is achieved by cascading multiple Transformers with increasing numbers of tokens, which are sequentially activated in an adaptive fashion at test time, i.e., the inference is terminated once a sufficiently confident prediction is produced. We further design efficient feature reuse and relationship reuse mechanisms across different components of the Dynamic Transformer to reduce redundant computations. Extensive empirical results on ImageNet, CIFAR-10, and CIFAR-100 demonstrate that our method significantly outperforms the competitive baselines in terms of both theoretical computational efficiency and practical inference speed. Code and pre-trained models (based on PyTorch and MindSpore) are available at https://github.com/blackfeather-wang/Dynamic-Vision-Transformer and https://github.com/blackfeather-wang/Dynamic-Vision-Transformer-MindSpore.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology View this paper on Syntology: its repositories, every harvested function with whether it ran, its licence and the call to fetch it.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2105.15075")

Code

Syntology Ran 2 of 3 code samples harvested from 1 repository linked to this paper; 1 has no recorded run. Of those that ran: 2 ran · our draft was wrong.

By repository: official repository: 3 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

blackfeather-wang/Dynamic-Vision-Transformer officialmentioned in papermentioned on GitHubpytorch report
blackfeather-wang/dynamic-vision-transformer-mindspore officialmentioned in papermentioned on GitHubmindspore report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

3 samples harvested; 2 ran; 0 honoured the contract we drafted; 1 has no recorded run. Read from Syntology's graph 2026-09-25; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
1unverified

Licence: 3 of the 3 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from blackfeather-wang/Dynamic-Vision-Transformer. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

dynamic_evaluate blackfeather-wang/Dynamic-Vision-Transformer/inference.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 8f49cc1ffec8b4b7 · report
dynamic_find_threshold blackfeather-wang/Dynamic-Vision-Transformer/inference.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 972a0b6e71a3501c · report
generate_logits blackfeather-wang/dynamic-vision-transformer/inference.py official repository unverified no licence file found · pointer only · 1399a5ed1c04887e · report

Tasks

AllComputational EfficiencyImage Classification

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Image Classification CIFAR-10 DVT (T2T-ViT-24) Percentage correct 98.53 #38 of 265 Archive leaderboard report
Image Classification CIFAR-100 DVT (T2T-ViT-24) Percentage correct 89.63 #28 of 211 Archive leaderboard report
Image Classification ImageNet DVT (T2T-ViT-12) GFLOPs 1.7 #701 of 1060 Archive leaderboard report
Image Classification ImageNet DVT (T2T-ViT-12) Top 1 Accuracy 80.43% #701 of 1060 Archive leaderboard report
Image Classification ImageNet DVT (T2T-ViT-10) GFLOPs 0.7 #743 of 1060 Archive leaderboard report
Image Classification ImageNet DVT (T2T-ViT-10) Top 1 Accuracy 79.74% #743 of 1060 Archive leaderboard report
Image Classification ImageNet DVT (T2T-ViT-7) GFLOPs 0.6 #830 of 1060 Archive leaderboard report
Image Classification ImageNet DVT (T2T-ViT-7) Top 1 Accuracy 78.48% #830 of 1060 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections