then rasterises them into 1D tokens zi2Rd. The sequence
of tokens input to the following transformer encoder is
z= [zcls;Ex1;Ex2;:::;ExN] +p; (1)
where the projection by Eis equivalent to a 2D convolution.
As shown in Fig. 1, an optional learned classiﬁcation token
zclsis prepended to this sequence, and its representation at
the ﬁnal layer of the encoder serves as the ﬁnal representation used by the classiﬁcation layer [17]. In addition, a
learned positional embedding, p2RNd, is added to the
tokens to retain positional information, as the subsequent
self-attention operations in the transformer are permutation
invariant. The tokens are then passed through an encoder
consisting of a sequence of Ltransformer layers. Each layer
`comprises of Multi-Headed Self-Attention [68], layer normalisation (LN) [2], and MLP blocks as follows:
y`=MSA (LN(z`)) +z`(2)
z`+1=MLP(LN(y`)) +y`: (3)
The MLP consists of two linear projections separated by a
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