only compute self-attention spatially, and then temporally.
Model 3: Factorised self-attention This model, in contrast, contains the same number of transformer layers as
Model 1. However, instead of computing multi-headed
self-attention across all pairs of tokens, z`, at layerl, we
factorise the operation to ﬁrst only compute self-attention
spatially (among all tokens extracted from the same temporal index), and then temporally (among all tokens extracted from the same spatial index) as shown in Fig. 5.
Each self-attention block in the transformer thus models
spatio-temporal interactions, but does so more efﬁciently
than Model 1 by factorising the operation over two smaller
sets of elements, thus achieving the same computational
complexity as Model 2. We note that factorising attention
over input dimensions has also been explored in [29, 78],
and concurrently in the context of video by [4] in their “Divided Space-Time” model.
This operation can be performed efﬁciently by reshaping
the tokens zfromR1ntnhnwdtoRntnhnwd(denoted
byzs) to compute spatial self-attention. Similarly, the input
We present pure-transformer based models for video classification, drawing
upon the recent success of such models in image classification. Our model
extracts spatio-temporal tokens from the input video, which are then encoded by
a series of transformer layers. In order to handle the long sequences of tokens
encountered in video, we propose several, efficient variants of our model which
factorise the spatial- and temporal-dimensions of the input. Although
transformer-based models are known to only be effective when large training
datasets are available, we show how we can effectively regularise the model
during training and leverage pretrained image models to be able to train on
comparatively small datasets. We conduct thorough ablation studies, and achieve
state-of-the-art results on multiple video classification benchmarks including
Kinetics 400 and 600, Epic Kitchens, Something-Something v2 and Moments in
Time, outperforming prior methods based on deep 3D convolutional networks. To
facilitate further research, we release code at
https://github.com/google-research/scenic/tree/main/scenic/projects/vivit
Anurag Arnab Mostafa Dehghani Georg Heigold Chen Sun Mario Lučić Cordelia Schmid