Token Shift Transformer for Video Classification

Hao Zhang, Yanbin Hao, Chong-Wah Ngo

Introduction

Video classification using Vision Transformers (ViTs) faces a significant hurdle: the "computational explosion" of 3D self-attention. While standard 2D Transformers excel at image recognition, extending them to the temporal dimension typically requires quadratic scaling of calculations across frames, making long-sequence processing prohibitively expensive.

To address this, the Token Shift Module (TokShift) is proposed—a zero-parameter, zero-FLOPs operator that enables standard 2D ViTs to capture motion dynamics effectively. By shifting a portion of global tokens across the temporal axis, the model gains "temporal vision" without increasing the computational burden per frame.

Methodology: The Token Shift Module

The core innovation of TokShift lies in how it manipulates the internal representations of a Vision Transformer. In a standard ViT, each frame is decomposed into spatial patch tokens, accompanied by a special [Class] token that serves as a global summary of the frame.

Comparison of different shifting strategies: (a) the original video tensor, (b) temporal shift, (c) patch shift, and (d) the proposed token shift.

Unlike previous methods that shift spatial patches (which can lead to "visual misalignment" as objects move), TokShift focuses exclusively on the [Class] tokens. For a frame at time $t$, a subset of its [Class] token channels is replaced by corresponding channels from the preceding ($t-1$) and succeeding ($t+1$) frames. This simple memory-shifting operation allows for temporal information exchange with zero additional parameters or FLOPs.

Architecture

The TokShift module is designed to be "plug-and-play." It is densely integrated into each encoder layer of a plain 2D ViT, effectively turning a static image model into a 3D video model.

The overall architecture of the Token Shift Transformer and the detailed structure of a Token Shift Encoder layer.

As shown in the architecture diagram, the module is placed within the Transformer block, specifically before the residual connections. This positioning is crucial; ablation studies indicate that placing it "prior to residual" allows temporal information to propagate more effectively through the subsequent attention and feed-forward blocks.

Key Insights

  • Verb vs. Noun Analogy: The authors conceptualize video frames as a combination of "visual nouns" (static spatial patches) and "visual verbs" (temporal motion). By shifting only the [Class] tokens, they exchange "verbs" across time while keeping the "nouns" spatially stable.
  • Avoiding Misalignment: Shifting spatial patches (Patch Shift) often degrades performance because moving objects change spatial coordinates across frames. The [Class] token, being a global representation, is invariant to these local spatial jitters.
  • Efficiency of Temporal Resolution: Results suggest that increasing the number of frames (temporal resolution) is a more cost-effective way to improve accuracy than increasing image size (spatial resolution).

Experimental Results

The model was evaluated on three major benchmarks: Kinetics-400, EGTEA-Gaze+, and UCF-101.

On the large-scale Kinetics-400 dataset, TokShift achieved a state-of-the-art 80.40% Top-1 accuracy using only 12 frames. This performance surpasses more complex 3D-CNN architectures like SlowFast and X3D-XXL while maintaining the computational efficiency of a standard 2D ViT. Furthermore, the model demonstrated strong transfer learning capabilities, reaching 66.56% on the egocentric EGTEA-Gaze+ dataset and 96.80% on UCF-101.

Conclusion

The Token Shift Transformer demonstrates that sophisticated temporal modeling does not necessitate heavy computational overhead. By leveraging the global nature of the [Class] token, TokShift provides a highly efficient path for adapting 2D image models to the video domain. While the baseline cost of 2D self-attention remains a factor, this approach significantly mitigates the additional costs typically associated with 3D video understanding.

Summary updated

BibTeX
@inproceedings{zhang2021token,
  author = {Hao Zhang and Yanbin Hao and Chong-Wah Ngo},
  title = {{Token Shift Transformer for Video Classification}},
  booktitle = {ACM Multimedia},
  year = {2021},
  doi = {10.1145/3474085.3475272},
}
Figure