DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification
arXiv:2106.02034
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. 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
Accepted to NeurIPS 2021. Project page: https://dynamicvit.ivg-research.xyz/
References in corpus (8)
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
- Distilling the Knowledge in a Neural Network
- Categorical Reparameterization with Gumbel-Softmax
- Transformer in Transformer
- Compressing Deep Convolutional Networks using Vector Quantization
- Conditional Positional Encodings for Vision Transformers
- DeepViT: Towards Deeper Vision Transformer
- High-Performance Large-Scale Image Recognition Without Normalization
Cited by in corpus (21)
- MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer
- CenterCLIP: Token Clustering for Efficient Text-Video Retrieval
- CDTrans: Cross-domain Transformer for Unsupervised Domain Adaptation
- Sparse DETR: Efficient End-to-End Object Detection with Learnable Sparsity
- SpeechFormer++: A Hierarchical Efficient Framework for Paralinguistic Speech Processing
- IA-RED: Interpretability-Aware Redundancy Reduction for Vision Transformers
- Dynamic Neural Networks: A Survey
- SHaRPose: Sparse High-Resolution Representation for Human Pose Estimation
- S-MLPv2: Improved Spatial-Shift MLP Architecture for Vision
- PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers
- Redundancy-aware Transformer for Video Question Answering
- Not All Images are Worth 16x16 Words: Dynamic Transformers for Efficient Image Recognition
- Homogeneous Tokenizer Matters: Homogeneous Visual Tokenizer for Remote Sensing Image Understanding
- Pruning Self-attentions into Convolutional Layers in Single Path
- AdaViT: Adaptive Vision Transformers for Efficient Image Recognition
- F3-Pruning: A Training-Free and Generalized Pruning Strategy towards Faster and Finer Text-to-Video Synthesis
- DS-Net++: Dynamic Weight Slicing for Efficient Inference in CNNs and Transformers
- NomMer: Nominate Synergistic Context in Vision Transformer for Visual Recognition
- Efficient Video Transformers with Spatial-Temporal Token Selection
- Token Pooling in Vision Transformers
- Focus on the Core: Efficient Attention via Pruned Token Compression for Document Classification