DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification

Yongming Rao, Wenliang Zhao, Benlin Liu, Jiwen Lu, Jie Zhou +1 more
6/3/2021
1,446 citations
cs.CVcs.AIcs.LG
transformer-attention

Official code: raoyongming/DynamicViT (673 stars, Jupyter Notebook, MIT, last commit 2023-07-11).

Abstract

Attention is sparse in vision transformers. We observe the final prediction in vision transformers is only based on a subset of most informative tokens, which is sufficient for accurate image recognition.

Show full abstract

Based on this observation, we propose a dynamic token sparsification framework to prune redundant tokens progressively and dynamically based on the input. Specifically, we devise a lightweight prediction module to estimate the importance score of each token given the current features. The module is added to different layers to prune redundant tokens hierarchically. To optimize the prediction module in an end-to-end manner, we propose an attention masking strategy to differentiably prune a token by blocking its interactions with other tokens. Benefiting from the nature of self-attention, the unstructured sparse tokens are still hardware friendly, which makes our framework easy to achieve actual speed-up. By hierarchically pruning 66% of the input tokens, our method greatly reduces 31%~37% FLOPs and improves the throughput by over 40% while the drop of accuracy is within 0.5% for various vision transformers. Equipped with the dynamic token sparsification framework, DynamicViT models can achieve very competitive complexity/accuracy trade-offs compared to state-of-the-art CNNs and vision transformers on ImageNet. Code is available at https://github.com/raoyongming/DynamicViT

View on arXivView PDF

Code Implementations(1)

MIT

[NeurIPS 2021] [T-PAMI] DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification

67381Jupyter Notebook, PythonJun 3, 20213 years agoMIT
computer-visiondeep-learningimage-classificationvision-transformers

Similar Papers

Cite this paper

@article{rao2021dynamicvit,
  title  = {DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification},
  author = {Yongming Rao and Wenliang Zhao and Benlin Liu and Jiwen Lu and Jie Zhou and Cho-Jui Hsieh},
  year   = {2021},
  eprint = {2106.02034},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2106.02034}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2106.02034.svg)](https://codeofpaper.com/paper/2106.02034)

Discussion