# Is Space-Time Attention All You Need for Video Understanding?

Video classification works with self-attention alone, dropping convolutions entirely

Gedas Bertasius, Heng Wang, Lorenzo Torresani · arXiv · 2021-2-9

- **Problem** Video models have relied on 2D or 3D convolutions, which reach distant space-time locations only by stacking layers. They are also costly to train and run on long, high-resolution clips.
- **Method** TimeSformer splits each frame into patch tokens, adds learned positional embeddings, and stacks Transformer blocks. Each block applies temporal attention first, then spatial attention, instead of joint attention over all patches.
- **Results** Divided space-time attention reaches 78.0 on Kinetics-400 and 59.5 on Something-Something-V2 with ImageNet-21K pretraining. TimeSformer-L reaches 80.7 top-1 on Kinetics-400.

## Why try a convolution-free video model

Video shares a useful property with language: frames arrive as an ordered sequence, and a short action segment is often only fully understood in the context of the rest of the clip. Self-attention Transformers already handle long-range dependencies in text well, so the question is whether the same mechanism can serve as the main operator for video rather than a supplement to convolution.

Until recently, 2D and 3D convolutions remained the core operators for spatiotemporal learning, and self-attention was mostly added on top of convolutional feature maps.

Convolutions carry strong inductive biases such as local connectivity and translation equivariance. These help when training data is small, but when data is abundant they can limit the functions a model can represent. A convolutional kernel captures short-range structure, and its receptive field grows only by stacking layers, so distant dependencies are reached only through repeated aggregation.

Self-attention compares feature activations at all space-time locations directly, so a single layer can relate patches far apart in both space and time.

Training deep CNNs on high-resolution and long videos is expensive, and in the image domain Transformers were reported to train and run faster than CNNs at a comparable budget. The study therefore asks whether a performant video architecture can be built by replacing convolution altogether with self-attention.

## How a clip becomes a token sequence

The input is a clip of F RGB frames, each of size H×W, sampled from the original video. Each frame is cut into N non-overlapping patches of size P×P, so that N = HW/P², and every patch is flattened into a vector of length 3P². Patches are taken from the individual frames, so a clip of F frames yields N×F patch vectors, indexed by spatial position p and frame index t.

A learnable matrix E maps each flattened patch to the embedding dimension D, and a learnable positional embedding for that patch's space-time position is added, giving the input token z^(0)\_(p,t) = E x\_(p,t) + e^pos\_(p,t). A learnable classification token is placed at the front of the sequence, so the sequence contains NF+1 tokens, and its embedding plays the role that a leading token plays in BERT-style models.

Once tokenized, the clip looks like a sentence of embedded words, which is why standard Transformer machinery can be applied without changes to the encoder.

## Self-attention over space-time tokens

Each block first applies LayerNorm to the previous representation and then projects it into a query, a key and a value for every head, each of dimension D\_h = D/A. In the unrestricted joint form, each query patch compares itself with the key of the classification token and with the keys of all patches in all frames, which gives NF+1 comparisons per query.

Standard Transformers compute similarity over all pairs of tokens, and with many patches per video this becomes the main cost, which motivates the reduced designs.

When attention is restricted to one dimension, the number of comparisons drops. Spatial-only attention compares each query with the classification token and the N patches of the same frame, giving N+1 comparisons. The weighted sums of value vectors from all heads are concatenated, projected and passed through a residual connection, and then an MLP with a second residual connection produces the block output.

The final clip representation is the layer-normalized classification token from the last block, and a one-hidden-layer MLP on top predicts the video classes.

## Dividing space and time within each block

Spatial-only attention is cheap but ignores dependencies across frames, so divided space-time attention adds a temporal step before the spatial one. That intermediate encoding is fed to the spatial step, where new query, key and value vectors are computed and attention runs within the frame, before the result reaches the MLP.

The two steps use distinct query, key and value matrices, one set for time and one for space, so the block has more learnable parameters than a single joint attention. Per patch, divided attention needs N+F+2 comparisons, while joint attention needs NF+1, so the factorization lowers the comparison count while keeping temporal reach.

Sparse local-global attention first attends to a local neighborhood of F×H/2×W/2 patches and then attends globally over the clip with a stride of 2 patches in time and in both spatial dimensions. Axial attention applies three successive steps over time, width and height, and extends the two-axis image formulation of earlier work with a temporal axis.

## Which attention scheme works best

This comparison starts from a ViT pretrained on ImageNet-21K, with clips of 8×224×224 and frames sampled at a rate of 1/32. Each scheme is evaluated on Kinetics-400 and on Something-Something-V2 (SSv2), and accuracy is reported at the video level.

Space attention reaches 76.9 on Kinetics-400 but only 36.6 on SSv2. Joint space-time attention reaches 77.4 and 58.5, and divided space-time attention reaches 78.0 and 59.5. Sparse local-global attention reaches 75.9 and 56.3, and axial attention reaches 73.5 and 56.2, both with more parameters than the space-only and joint variants. Divided space-time attention has the highest value on both datasets among the five schemes in this comparison.

The authors read the strong space-only result on Kinetics-400 as a sign that spatial cues dominate that benchmark, and they note that space-only attention performs poorly on SSv2, which depends on temporal modeling.

Joint space-time attention ran out of GPU memory once the spatial frame resolution reached 448 pixels, or when the clip reached 32 frames. A cost plot shows joint attention rising sharply with resolution and frame count while divided attention scales more gracefully. For this reason, the rest of the experiments use divided space-time self-attention blocks.

## Cost and training time against 3D CNNs

The baselines are SlowFast 8×8 R50 and I3D 8×8 R50, both trained and evaluated on Kinetics-400. TimeSformer therefore has the larger parameter count but the lowest inference cost of the three models in this comparison.

Training on Kinetics-400 with ImageNet-1K initialization took SlowFast 8×8 R50 3 840 Tesla V100 GPU hours to reach 75.6%, and I3D took 1 440 GPU hours to reach 73.4%. TimeSformer, also initialized from ImageNet-1K, needed 416 Tesla V100 GPU hours to reach 75.8%. When SlowFast was given a budget of 448 GPU hours, its accuracy dropped to 70.0%, and I3D at 444 GPU hours reached 71.0%.

On 20K Kinetics-400 validation videos using 8 Tesla V100 GPUs, the inference run took 14.88 hours for SlowFast and 36 minutes for the default TimeSformer. TimeSformer-HR and TimeSformer-L took 1.06 hours and 2.6 hours on the same run, and the authors note that their TFLOPs are comparable to SlowFast's while the runtimes are much lower. These runtime numbers come from one fixed inference setup and do not transfer to other hardware.

## Initialization from image pretraining

The authors judge training from scratch difficult because the model has a large number of parameters, so TimeSformer is initialized from ImageNet weights before video training.

With a longer schedule and more data augmentation, training directly on Kinetics-400 without ImageNet pretraining reached 64.8% video-level accuracy. This is far below the pretrained results, so the subsequent studies all use ImageNet pretraining.

The authors explain the gain on Kinetics-400 by that benchmark leaning toward scene information, which benefits from the larger pretraining set, whereas SSv2 needs spatiotemporal reasoning that pretraining does not address.

## Effect of the number of training videos

TimeSformer, SlowFast R50 and I3D R50 were trained on 25%, 50%, 75% and 100% of Kinetics-400 and Something-Something-V2, all with ImageNet-1K pretraining. On Kinetics-400, TimeSformer is best at every training subset size. On SSv2, TimeSformer is the strongest model only at 75% and 100% of the data, which the authors tie to the more complex temporal patterns that the dataset requires.

## Token count and positional embeddings

Raising the spatial resolution adds patches per frame, and adding frames adds tokens, so both change the sequence length the Transformer processes. Increasing the spatial crop up to a point and increasing the number of input frames both raise clip-level accuracy on Kinetics-400.

These are positional embedding variants, which change the encoding of each token, not the attention scheme of the block.

## Kinetics-400 and Kinetics-600 results

On Kinetics-400, TimeSformer reaches 78.0 top-1 and 93.7 top-5 at 0.59 TFLOPs, TimeSformer-HR reaches 79.7 and 94.4 at 5.11 TFLOPs, and TimeSformer-L reaches 80.7 and 94.7 at 7.14 TFLOPs. The Kinetics-400 TimeSformer rows use ImageNet-21K pretraining, and in that table TimeSformer-L has the highest top-1 value. Other rows include SlowFast at 79.8 top-1 with 7.0 TFLOPs and X3D-XXL at 80.4 top-1 with 5.8 TFLOPs.

Most prior methods average 10 temporal clips with 3 spatial crops at inference, whereas TimeSformer uses 3 spatial crops from a single temporal clip.

On Kinetics-600, TimeSformer reaches 79.1 top-1 and 94.4 top-5, TimeSformer-HR reaches 81.8 and 95.8, and TimeSformer-L reaches 82.2 top-1 and 95.6 top-5. TimeSformer-L is the top-1 leader in that Kinetics-600 table.

## Something-Something-V2 and Diving-48

With ImageNet-1K pretraining on SSv2, the default TimeSformer scores 59.5, below SlowFast at 61.7, while TimeSformer-HR scores 62.2 and TimeSformer-L scores 62.4. The authors read these results as evidence that the factorized design is promising on temporally heavy data, though the default model trails the best models.

On Diving-48, TimeSformer scores 74.9, TimeSformer-HR scores 78.0 and TimeSformer-L scores 81.0, against 77.6 for a reproduced SlowFast 16×8 R101. The Diving-48 comparison is limited to this reproduced SlowFast model because of a known issue with a previous version of the labels.

## Long-term task classification on HowTo100M

HowTo100M contains around 1M instructional web videos with over 23K task labels, and its videos average about 7 minutes, far longer than typical action recognition clips. The evaluation keeps categories with at least 100 videos, which gives 120K videos over 1059 task categories, split into 85K training and 35K testing videos.

Both models are pretrained on Kinetics-400 and then fine-tuned on HowTo100M, and four input lengths of 8, 32, 64 and 96 frames are compared. At test time, enough non-overlapping clips are sampled to cover each video, and clip predictions are averaged to give the video-level result.

SlowFast reaches 48.2, 50.8, 51.5 and 51.2 top-1 for 8, 32, 64 and 96 frames, while TimeSformer reaches 56.8, 61.2, 62.2 and 62.6 at the same lengths. Trained from ImageNet-1K without Kinetics-400 pretraining, TimeSformer reaches 52.8, 58.4, 59.2 and 59.4 for 8, 32, 64 and 96 frames, and with ImageNet-21K it reaches 56.0, 59.2, 60.2 and 62.1.

## Model size, patch size and attention order

The authors suspect the current datasets are too small to benefit from more capacity, since the Base model already has 121M parameters.

Using a patch size of 32 instead of 16 gave results about 3% worse, which the authors attribute to coarser spatial granularity. Patch sizes below 16 were not trained because of their higher computational cost.

Applying spatial attention first and temporal attention second lowers accuracy by 0.5% on both Kinetics-400 and SSv2. A parallel space-time self-attention variant is 0.4% lower than divided space-time attention.

## Attention and feature visualizations

Attention rollout is applied to Something-Something-V2 clips to show which input regions the output token draws on. The authors report that the model attends to the configuration of the hand when it is visible and to the object alone when the hand is not visible.

A t-SNE projection of features from Something-Something-V2 videos shows that divided space-time attention produces more separable class clusters than space-only attention or ViT. These are qualitative visualizations and do not replace the accuracy comparisons above.

## Training and inference settings

Momentum is 0.9 and weight decay is 0.0001. Training frames are sampled at a rate of 1/32, and the shorter side is resized to a random value in \[256, 320\] before a 224×224 crop is taken.

At inference, one temporal clip is taken from the middle of the video, the shorter side is scaled to 224 pixels, and three 224×224 crops are taken and their softmax scores averaged. Kinetics-400 has 240K training and 20K validation videos over 400 categories, and Something-Something-V2 has 170K training and 25K validation videos over 174 categories.

## Limitations

Clips longer than 96 frames could not be tested because of GPU memory constraints. The default TimeSformer scores below SlowFast on SSv2, and the Diving-48 comparison uses only a reproduced SlowFast 16×8 R101 model.

The data-scale study shows that TimeSformer is the strongest model on SSv2 only at 75% and 100% of the training data. The authors plan to extend the method to action localization, video captioning and question answering, and these tasks were not tested here.

## Paper info

- **Authors**: Gedas Bertasius, Heng Wang, Lorenzo Torresani
- **Venue**: arXiv · Preprint
- **First published**: 2021-2-9
- **Added**: 2026-11-12
- **Updated**: 2021-6-9
- **Version**: v4
- **arXiv**: 2102.05095
- **Category**: cs.CV
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2102.05095v4) · [PDF ↗](https://arxiv.org/pdf/2102.05095v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Gedas Bertasius, Heng Wang, Lorenzo Torresani (2021). Is Space-Time Attention All You Need for Video Understanding?. arXiv:2102.05095v4. https://arxiv.org/abs/2102.05095v4

**BibTeX**

```
@misc{bertasius2021space,
  title = {{Is Space-Time Attention All You Need for Video Understanding?}},
  author = {Gedas Bertasius and Heng Wang and Lorenzo Torresani},
  year = {2021},
  eprint = {2102.05095},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2102.05095v4}
}
```

## Other paper commentary

- [Return of Frustratingly Easy Domain Adaptation](https://refivu.com/en/papers/0a776e2c-6337-4850-9be1-86de976005d2-return-of-frustratingly-easy-domain-adaptation.md)
- [Celeb-DF: A Large-scale Challenging Dataset for DeepFake Forensics](https://refivu.com/en/papers/127fcad1-737e-4bb9-b7b5-7c87f1ab7614-celeb-df-a-large-scale-challenging-dataset-for.md)
- [Cascade R-CNN: High Quality Object Detection and Instance Segmentation](https://refivu.com/en/papers/484c94a6-ca7a-4e4d-a933-9ea5ec919a68-cascade-r-cnn-high-quality-object-detection-and.md)
- [DSSD : Deconvolutional Single Shot Detector](https://refivu.com/en/papers/800d2066-c083-45ac-bb3d-507e72445f62-dssd-deconvolutional-single-shot-detector.md)
- [Activation Functions: Comparison of trends in Practice and Research for Deep Learning](https://refivu.com/en/papers/b7691c32-6640-47d3-9dda-c4586bd48272-activation-functions-comparison-of-trends-in-practice-and.md)
- [Deep Learning for Sensor-based Activity Recognition: A Survey](https://refivu.com/en/papers/2047ba14-2bcc-42f2-a0fe-57280553acee-deep-learning-for-sensor-based-activity-recognition-a.md)
- [PointConv: Deep Convolutional Networks on 3D Point Clouds](https://refivu.com/en/papers/c9a5b52f-78bd-452f-b508-b85a37101523-pointconv-deep-convolutional-networks-on-3d-point-clouds.md)
- [Man is to Computer Programmer as Woman is to Homemaker? Debiasing Word Embeddings](https://refivu.com/en/papers/54f76c5c-e7e0-4849-8c34-62d4d7e29119-man-is-to-computer-programmer-as-woman-is.md)
- [Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Models](https://refivu.com/en/papers/d7cee9c8-e38d-4e30-b35b-f069db83f282-qwen3-embedding-advancing-text-embedding-and-reranking.md)
- [Stacked Attention Networks for Image Question Answering](https://refivu.com/en/papers/aa94a5f2-b4fb-441a-af4b-22eda9ad2985-stacked-attention-networks-for-image-question-answering.md)

## Terms in this paper

- [Transformer](https://refivu.com/en/terms/48e8be2570bc-transformer)
- [self-attention](https://refivu.com/en/terms/426589b81077-self-attention)
- [classification accuracy](https://refivu.com/en/terms/3c67905d3166-classification-accuracy)
- [ImageNet-1K](https://refivu.com/en/terms/d8d6444bd460-imagenet-1k)
- [Vision Transformer](https://refivu.com/en/terms/143abf165d88-vision-transformer)
- [LayerNorm](https://refivu.com/en/terms/71749b6cdbf4-layernorm)
- [I3D](https://refivu.com/en/terms/a6f22951e04b-i3d)
- [Positional Embedding](https://refivu.com/en/terms/ce0faaab48ab-positional-embedding)
- [TimeSformer](https://refivu.com/en/terms/13ac3b0914d3-timesformer)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/b6bd7278-3728-4d96-9fe0-5f483de3f3bd-is-space-time-attention-all-you-need-for)
