Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification

About

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. 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

Yongming Rao, Wenliang Zhao, Benlin Liu, Jiwen Lu, Jie Zhou, Cho-Jui Hsieh• 2021

Related benchmarks

TaskDatasetResultRank
Image ClassificationImageNet-1K 1.0 (val)
Top-1 Accuracy83
1866
Image ClassificationImageNet-1k (val)
Top-1 Accuracy79.3
1453
ClassificationImageNet-1K 1.0 (val)
Top-1 Accuracy (%)79.3
1155
Image ClassificationImageNet-1k (val)
Top-1 Accuracy79.8
840
Image ClassificationImageNet-1K
Top-1 Acc78.3
524
Image ClassificationImageNet-1k (val)
Top-1 Accuracy81.3
512
Image ClassificationVTAB 1K
Overall Mean Accuracy60.1
204
Image ClassificationImageNet-1K 1 (val)
Top-1 Accuracy83.8
119
Image ClassificationImageNet ILSVRC2012 (val)
Top-1 Accuracy81.3
47
Image ClassificationImageNet-1K 1.0 (val)
Top-1 Accuracy81.4
40
Showing 10 of 23 rows

Other info

Follow for update