Introduction
Video action recognition is a fundamental task in computer vision that requires the simultaneous modeling of spatial features—identifying objects and scenes—and temporal dynamics—understanding how these elements evolve over time. While 2D Transformers have achieved remarkable success in image processing, extending them to the video domain typically involves 3D spatiotemporal attention. However, vanilla 3D Transformers suffer from a quadratic computational complexity of $O(N^2 T^2)$, where $N$ is the number of spatial patches and $T$ is the number of frames. This leads to significant memory overhead and slow inference speeds.
To address this, researchers have proposed various factorization methods to separate spatial and temporal attention, but these often introduce additional parameters and computational costs. This paper introduces Temporal Patch Shift (TPS), a zero-parameter, plug-and-play module that enables 2D Transformers to perform effective spatiotemporal modeling with the efficiency of 2D image processing.
The Temporal Patch Shift (TPS) Mechanism
The core innovation of this work is the TPS operator, which transforms a standard 2D self-attention layer into a spatiotemporal one without adding any learnable parameters.
1. The Shift Operation
Instead of calculating attention across all frames simultaneously, TPS replaces a subset of patches in a given frame with corresponding patches from neighboring frames ($t-1$ or $t+1$). When a standard 2D Self-Attention (SA) layer processes this "mixed" frame, it naturally performs spatiotemporal attention because the tokens it compares originate from different points in the temporal sequence.
2. Mosaic Patterns
To ensure the model maintains a representative sample of the video's spatial and temporal content, the authors employ a "mosaic" shifting pattern. Inspired by the Bayer filter used in digital camera sensors, this structured pattern ensures an even spatial distribution of temporal information. This prevents the model from losing too much spatial context in any specific region while gaining temporal awareness.
3. Temporal Channel Shift (TCS)
In addition to patch shifting, the authors utilize Temporal Channel Shift (TCS). While TPS is space-wise sparse but channel-wise dense, TCS is channel-wise sparse but space-wise dense. The authors argue that these two techniques are orthogonal and complementary, allowing the model to capture motion more effectively when used in tandem.
The Patch Shift Transformer (PST)
By inserting TPS modules into existing hierarchical backbones, such as the Swin Transformer, the authors create the Patch Shift Transformer (PST). Because TPS is a simple swap operation, it adds zero parameters and negligible FLOPs to the base model. Furthermore, as these layers are stacked throughout a deep network, the temporal receptive field expands naturally, allowing the model to capture long-range dependencies across many frames despite only shifting between immediate neighbors in a single layer.
Experimental Results
The PST was evaluated against several competitive benchmarks, demonstrating a superior balance of efficiency and accuracy.
Efficiency and Throughput
Compared to the Video-Swin Transformer, the PST-T variant is significantly more efficient:
- Memory Usage: 76% reduction in memory consumption.
- Inference Speed: 2x faster throughput.
- Parameters: Zero additional parameters compared to the 2D backbone.
Benchmark Performance
- Something-Something (Sth-Sth) V2: PST achieved 69.8% top-1 accuracy, outperforming heavier models like TimeSformer and ViViT on this motion-heavy dataset.
- Kinetics400: The model reached 82.5% top-1 accuracy, remaining competitive with state-of-the-art 3D-CNNs and specialized video Transformers.
- Diving-48: On this fine-grained dataset requiring long-term temporal modeling, PST achieved 86.0% top-1 accuracy.
Conclusion and Future Work
Temporal Patch Shift (TPS) provides a highly efficient alternative to full 3D attention for video tasks. By leveraging simple patch-swapping and mosaic patterns, it allows 2D Transformers to achieve state-of-the-art results in action recognition with minimal computational overhead. While the current implementation relies on sparse temporal connectivity per layer, the stacking of layers effectively builds a global temporal view. Future research may explore the application of TPS to other video-based tasks, such as object detection and segmentation, where computational efficiency is a critical bottleneck.
Summary updated