Skip to main content
QUICK REVIEW

[Paper Review] AdaViT: Adaptive Vision Transformers for Efficient Image Recognition

Lingchen Meng, Hengduo Li|arXiv (Cornell University)|Nov 30, 2021
Advanced Neural Network ApplicationsComputer Science49 references15 citations
TL;DR

AdaViT introduces an adaptive computation framework for vision transformers that dynamically selects patches, self-attention heads, and transformer blocks per input image to improve inference efficiency. By jointly training a lightweight decision network with the backbone using Gumbel-Softmax, AdaViT achieves over 2× faster inference than state-of-the-art models with only a 0.8% accuracy drop on ImageNet.

ABSTRACT

Built on top of self-attention mechanisms, vision transformers have demonstrated remarkable performance on a variety of vision tasks recently. While achieving excellent performance, they still require relatively intensive computational cost that scales up drastically as the numbers of patches, self-attention heads and transformer blocks increase. In this paper, we argue that due to the large variations among images, their need for modeling long-range dependencies between patches differ. To this end, we introduce AdaViT, an adaptive computation framework that learns to derive usage policies on which patches, self-attention heads and transformer blocks to use throughout the backbone on a per-input basis, aiming to improve inference efficiency of vision transformers with a minimal drop of accuracy for image recognition. Optimized jointly with a transformer backbone in an end-to-end manner, a light-weight decision network is attached to the backbone to produce decisions on-the-fly. Extensive experiments on ImageNet demonstrate that our method obtains more than 2x improvement on efficiency compared to state-of-the-art vision transformers with only 0.8% drop of accuracy, achieving good efficiency/accuracy trade-offs conditioned on different computational budgets. We further conduct quantitative and qualitative analysis on learned usage polices and provide more insights on the redundancy in vision transformers.

Motivation & Objective

  • Address the high computational cost of vision transformers, which scales quadratically with input patches and model depth.
  • Identify and exploit redundancy in vision transformers by recognizing that complex images require more computation than simple ones.
  • Develop an end-to-end trainable framework that learns instance-specific usage policies for patches, attention heads, and transformer blocks.
  • Achieve efficient inference without sacrificing accuracy by dynamically allocating computational resources based on input complexity.
  • Provide a flexible, model-agnostic solution that can be applied to various vision transformer backbones with minimal architectural changes.

Proposed method

  • Introduce a lightweight decision network attached to each transformer block to predict binary usage decisions for patches, attention heads, and blocks.
  • Use Gumbel-Softmax during training to enable differentiable sampling of discrete decisions, enabling end-to-end optimization.
  • Optimize the decision network jointly with the vision transformer backbone using a composite loss combining cross-entropy classification loss and a usage cost loss.
  • Control the target computational budget via a hyperparameter γ ∈ (0,1], representing the percentage of full model cost allowed during training.
  • Enable per-input adaptivity: easy images use fewer patches/heads/blocks; hard images use more, based on learned policies.
  • Design the framework to be model-agnostic, allowing integration with various vision transformer architectures like DeiT and T2T-ViT.

Experimental results

Research questions

  • RQ1Can vision transformers dynamically adjust their computational load per input image based on input complexity?
  • RQ2To what extent can redundant patches, attention heads, and transformer blocks be pruned without significant accuracy drop?
  • RQ3How does the learned adaptive computation policy vary across different image classes and complexity levels?
  • RQ4Can an end-to-end trainable, lightweight decision network effectively learn to allocate computational resources in a differentiable manner?
  • RQ5What is the trade-off between inference efficiency and accuracy when using adaptive computation in vision transformers?

Key findings

  • AdaViT achieves more than 2× improvement in inference efficiency compared to state-of-the-art vision transformers on ImageNet, with only a 0.8% accuracy drop.
  • The method learns to allocate more computation to complex, cluttered images (e.g., 'barber shop', 'toyshop') and less to simple, object-centric images (e.g., 'parachute', 'kite').
  • Patch selection shows a progressive reduction in computation across deeper layers, indicating higher redundancy in later stages of the backbone.
  • The decision network learns to preserve more computation in later transformer blocks, which are more critical for final prediction.
  • Qualitative analysis confirms that the model focuses on discriminative image regions in later layers, with fewer patches active as the network deepens.
  • AdaViT generalizes across backbones: it achieves superior efficiency/accuracy trade-offs when applied to DeiT-small and T2T-ViT, outperforming both standard and random baseline variants.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.