Keeping Your Eye on the Ball: Trajectory Attention in Video Transformers
Year: 2022

Abstract:
In video transformers, the time dimension is often treated in the same way as the two spatial dimensions. However, in a scene where objects or the camera may move, a physical point imaged at one location in frame t may be entirely unrelated to what is found at that location in frame t+ k. These temporal correspondences should be modeled to facilitate learning about dynamic scenes. To this end, we propose a new drop-in block for video transformers—trajectory attention—that aggregates information along implicitly determined motion paths. We additionally propose a new method to address the quadratic dependence of computation and memory on the input size, which is particularly important for high resolution or long videos. While these ideas are useful in a range of settings, we apply them to the specific task of video action recognition with a transformer model and obtain state-of-the-art results on the Kinetics, Something–Something V2, and Epic-Kitchens datasets. Code and models are available at: https://github.com/facebookresearch/ Motionformer.

heading: 1 Introduction
text: Transformers [75] have become a popular architecture across NLP [32], vision [20] and speech [5]. The self-attention mechanism in the transformer works well for different types of data and across domains. However, its generic nature and its lack of inductive biases also mean that transformers typically require extremely large amounts of data for training [56, 9], or aggressive domain-specific augmentations [71]. This is particularly true for video data, for which transformers are also applicable [50], but where statistical inefficiencies are exacerbated. While videos carry rich temporal information, they can also contain redundant spatial information from neighboring frames. Vanilla self-attention applied to videos compares pairs of image patches extracted at all possible spatial locations and frames. This can lead it to focus on the redundant spatial information rather than the temporal information, as we show by comparing normalization strategies in our experiments.
We therefore contribute a variant of self-attention, called trajectory attention, which is better able to characterize the temporal information contained in videos. For the analysis of still images,
∗Equal contribution.
35th Conference on Neural Information Processing Systems (NeurIPS 2021).
spatial locality is perhaps the most important inductive bias, motivating the design of convolutional networks [42] and the use of spatial encodings in vision transformers [20]. This is a direct consequence of the local structure of the physical world: points that belong to the same 3D object tend to project to pixels that are close to each other in the image. By studying the correlation of nearby pixels, we can thus learn about the objects.
Videos are similar, except that 3D points move over time, thus projecting on different parts of the image along certain 2D trajectories. Existing video transformer methods [8, 3, 50] disregard these trajectories, pooling information over the entire 3D space-time feature volume [3, 50], or pooling axially across the temporal dimension [8]. We contend that pooling along motion trajectories would provide a more natural inductive bias for video data, allowing the network to aggregate information from multiple views of the same object or region, to reason about how the object or region is moving (for example, the linear and angular velocities), and to be invariant to camera motion.
We leverage attention itself as a mechanism to find these trajectories. This is inspired by methods such as RAFT [70], which showed that excellent estimates of optical flow can be obtained from the correlation volume obtained by comparing local features across space and time. We observe that the joint attention mechanism for video transformers computes such a correlation volume as an intermediate result. However, subsequent processing collapses the volume without consideration for its particular structure. In this work, we seek instead to use the correlation volume to guide the network to pool information along motion paths.
We also note that visual transformers operate on image patches which, differently from individual pixels, cannot be assumed to correspond to individual 3D points and thus to move along simple 1D trajectories. For example, in Figure 1, depicting the action ‘kicking soccer ball’, the ball spans up to four patches, depending on the specific video frame. Furthermore, these patches contain a mix of foreground (the ball) and background objects, thus at least two distinct motions. Fortunately, we are not forced to select a single putative motion: the attention mechanism allows us to assemble a motion feature from all relevant ‘ball regions’.
Inspired by Nyströmformer [85], we also propose a principled approximation to self-attention, Orthoformer. Our approximation sets state-of-the-art performance on the recent Long Range Arena (LRA) benchmark [69] for evaluating efficient attention approximations and generalizes beyond the video domain to long text and high resolution images, with lower FLOPS and memory requirements compared to alternatives, Nyströmformer and Performer [15]. Combining our approximation with trajectory attention allows us to significantly improve its computational and memory efficiency. With our contributions, we set state-of-the-art results on four video action recognition benchmarks.

heading: 2 Related Work
text: Video representations and 3D-CNNs. Hand-crafted features were originally used to convert video data into a representation amenable to analysis by a shallow linear model. Such representations include SIFT-3D [60], HOG3D [39], and IDT [76]. Since the breakthrough of AlexNet [40] on the ImageNet classification benchmark [58], which demonstrated the empirical benefits of deep neural networks to learn representations end-to-end, there have been many attempts to do the same for video. Architectures with 3D convolutions—3D-CNNs—were originally proposed to learn deep video representations [72]. Since then, improvements to this paradigm include the use of ImageNet-inflated weights [11], the space-time decomposition of 3D convolutions [54, 74, 84], channel-separated convolutions [73], non-local blocks [79], and attention layers [13]. Optical flow-based pooling can be used instead of temporal convolutions to improve the representation’s robustness to camera and object motions [1]. Our approach shares this motivation.
Vision transformers. The transformer architecture [75], originally proposed for natural language processing, has recently gained traction in the computer vision domain. The vision transformer (ViT) [20] decomposes an image into a sequence of 16× 16 words and uses a multi-layer transformer to perform image classification. To improve ViT’s data efficiency, DeiT [71] used distillation from a strong teacher model and aggressive data augmentation. Transformers have also been used in a variety of vision image tasks, such as image representation learning [12, 82, 18, 59], image generation [51], object detection [48, 10], video question-answering [35], few-shot learning [19], and image–text [49, 63, 67, 44, 68], video-text [65, 64, 89, 25, 53, 2, 6], and video-audio [43, 52, 29] representation learning.
Attention for video recognition. The self-attention operation proposed in the transformer [75] have been adapted to video recognition tasks. Wang et al. [79] propose the non-local mean operation for video action recognition, which is equivalent to the standard transformer self-attention applied uniformly across space and time, while our proposed trajectory attention does not treat the space and time dimensions equivalently. Zhao et al. [87] propose a CNN architecture that explicitly predicts trajectories and aggregates information along them using a convolution operation. In contrast, our transformer architecture does not explicitly predict trajectories, but instead provides an inductive bias that encourages the network to consider motion trajectories where useful. Concurrent works [8, 3, 50, 21] have also adapted the self-attention operation to the spatio-temporal nature of videos, however, these approaches do not have a mechanism for reasoning about motion paths, treating time as just another dimension, unlike our approach.
Efficient attention. Due to the quadratic complexity of self-attention, there has been a significant amount of research on how to reduce its computational complexity with respect to time and memory use. Sparse attention mechanisms [14] were used to reduce self-attention complexity to O(n √ n), and locality-sensitivity hashing was used by Reformer [38] to further reduce this toO(n log n). More recently, linear attention mechanisms have been introduced, namely Longformer [7], Linformer [78], Performer [15] and Nyströmformer [85]. The Long Range Arena benchmark [69] was recently introduced to compare these different attention mechanisms.
Temporal correspondences and optical flow. There are many approaches that aim to establish explicit correspondences between video frames as a way to reason about camera and object motion. For short-range correspondences across time, optical flow algorithms [30, 66, 70] are highly effective. In particular, RAFT [70] showed the effectiveness of an all-pairs inter-frame correlation volume as an encoding, which is essentially an attention map. All-pairs intra-frame correlations were subsequently shown to help resolve correspondence ambiguities [34]. For longer-range correspondences, object tracking by repeated detection [57] and data association can be used. In contrast to these approaches, our work does not explicitly establish temporal correspondences, but facilitates implicit correspondence learning via trajectory attention. Jabri et al. [31] estimate correspondences in a similar way, framing the problem as a contrastive random walk on a graph and apply explicit guidance via a cycle consistency loss. Incorporating such guidance into a video transformer is an interesting direction.

heading: 3 Trajectory Attention for Video Data
text: Our goal is to modify the attention mechanism in transformers to better capture the information contained in videos. Consider an input video I ∈ RT ′×3×H×W consisting of T ′ frames of resolution
H ×W . As in existing video transformer models [8, 3], we pre-process the video into a sequence of ST tokens xst ∈ RD, for a spatial resolution of S and a temporal resolution of T . We use a cuboid embedding [3, 21], where disjoint spatio-temporal cubes from the input volume are linearly projected to RD (equivalent to a 3D convolution with downsampling). We also test an embedding of disjoint image patches [20]. A learnable positional encoding e ∈ RD is added to the video embeddings for spatial and temporal dimensions separately, resulting in the code zst = xst+ess+e t t. Finally, a learnable classification token zcls is added to the sequence of tokens, like in the BERT Transformer [32], to reason about the video as a whole. For clarity, we elide the classification token from our treatment in the sequel.
We now have a set of tokens that form the input to a sequence of transformer layers that, as in ViT [20], consist of Layer Norm (LN) operations [4], multi-head attention (MHA) [75], residual connections [27], and a feed-forward network (MLP):
y = MHA(LN(z)) + z; z′ = MLP(LN(y)) + y. (1)
In the next section, we shall focus on a single head of the attention operation, and demonstrate how self-attention can realize a suitable inductive bias for video data. For clarity of exposition, we abuse the notation slightly, neglecting the layer norm operation and using the same dimensions for single-head attention as for multi-head attention.

heading: 3.1 Video self-attention
text: The self-attention operation begins by forming a set of query-key-value vectors qst,kst,vst ∈ RD, one for each space-time location st in the video. These are computed as linear projections of the input zst, that is, qst = Wqzst, kst = Wkzst, and vst = Wvzst, for projection matrices Wi ∈ RD×D. A direct application of attention across space-time (called joint space-time attention [8, 3]) computes:
yst = ∑ s′t′ vs′t′ · exp〈qst,ks′t′〉∑ s̄t̄ exp〈qst,ks̄t̄〉 . (2)
In this way, each query qst is compared to all keys ks′t′ using dot products, the results are normalized using the softmax operator, and the weights thus obtained are used to average the values corresponding to the keys. Compared to a standard transformer, we have omitted for brevity the softmax temperature parameter D1/2 and instead assume that the queries and keys have been divided by D1/4.
One issue with this formulation is that it has quadratic complexity in both space and time, i.e., O(S2T 2). An alternative is to restrict attention to either space or time (called divided space-time attention):
yst = ∑ s′ vs′t · exp〈qst,ks′t〉∑ s̄ exp〈qst,ks̄t〉 (space); yst = ∑ t′ vst′ · exp〈qst,kst′〉∑ t̄ exp〈qst,kst̄〉 (time). (3)
This reduces the complexity to O(S2T ) and O(ST 2), respectively, but only allows the model to analyse time and space independently. This is usually addressed by interleaving [8] or stacking [3] the two attention modules in a sequence.
Different to both of these approaches, we perform attention along trajectories, the probabilistic path of a token between frames.2 For each space-time location st (the trajectory ‘reference point’) and corresponding query qst, we construct a set of trajectory tokens ỹstt′ , representing the pooled information weighted by the trajectory probability. The trajectory extends for the duration of the video sequence and its tokens ỹstt′ ∈ RD at different times t′ are given by:
ỹstt′ = ∑ s′ vs′t′ · exp〈qst,ks′t′〉∑ s̄ exp〈qst,ks̄t′〉 . (4)
Note that the attention in this formula is applied spatially (index s) and independently for each frame. Intuitively, this pooling operation implicitly seeks the location of the trajectory at time t′ by comparing the trajectory query qst to the keys ks′t′ at time t′.
Once the trajectories are computed, we further pool them across time to reason about intra-frame information/connections. To do so, the trajectory tokens are projected to a new set of queries, keys and values as usual:
q̃st = W̃q ỹstt, k̃stt′ = W̃k ỹstt′ , ṽstt′ = W̃v ỹstt′ . (5)
Like qst before, the updated reference query q̃st corresponds to the trajectory reference point st and contains information spatially-pooled from across the reference frame t. This new query is used to pool across the new time (trajectory) dimension by applying 1D attention:
yst = ∑ t′ ṽstt′ · exp〈q̃st, k̃stt′〉∑ t̄ exp〈q̃st, k̃stt̄〉 . (6)
Like joint space-time attention, our approach has quadratic complexity in both space and time, O(S2T 2), so has no computational advantage and is in fact slower than divided space-time attention. However, we demonstrate better accuracy than both joint and divided space-time attention mechanisms. We also provide fast approximations in Section 3.2. A flowchart of the full trajectory attention operation is shown in tensor form in Figure 2.

heading: 3.2 Approximating attention
text: To complement our trajectory attention, we also propose an approximation scheme to speed up calculations. This scheme is generic and applies to any attention-like pooling mechanism. We thus switch to a generic transformer-like notation to describe it. Namely, consider query-key-value matrices Q,K,V ∈ RD×N such that the query-key-value vectors are stored as columns qi,ki,vi ∈ RD in these matrices.
In order to obtain an efficient decomposition of the attention operator, we will rewrite it using a probabilistic formulation. Let Aij ∈ {0, 1} be a categorical random variable indicating whether the jth input (with key vector kj ∈ RD) is assigned to the ith output (with query vector qi ∈ RD), with∑
j Aij = 1. The attention operator uses a parametric model of the probability of this event based on the multinomial logistic function, i.e., the softmax operator S(·):3
P (Ai:) = S(qTi K), (7) where the subscript : denotes a full slice of the input tensor in that dimension. We now introduce the latent variables U`j ∈ {0, 1}, which similarly indicate whether the jth input is assigned to the `th prototype, an auxiliary vector which we denote by p` ∈ RD. We can use the laws of total and conditional probability to obtain:
P (Aij) = ∑
` P (Aij | U`j)P (U`j). (8)
Note that the latent variables that we chose are independent of the inputs (keys). They use the same parametric model, but with parameters P ∈ RD×R (the concatenated prototype vectors p`):
2Here, we refer to the trajectory as the motion between pairs of frames, rather than a multi-frame path. 3I.e. [S(z)]i = exp(zi/ √ D)/ ∑ j exp(zj/ √ D). For matrix inputs, the sum is over the columns.
P (U) = S(PTK). Eq. 8 is exact, even under the parametric model for P (U), though the corresponding true distribution P (A | U) is intractable. We now approximate the conditional probability P (A | U) with a similar parametric model:
P̃ (A | U) = S(QTP), (9) where Q ∈ RD×N concatenates all query vectors horizontally. Substituting equations 7–9 we write the full approximate attentionÃ, multiplied by an arbitrary matrix V (which in the case of a transformer contains the values of the key–value pairs stacked as rows):
P̃ (A)V = S(QTP) ( S(PTK)V ) . (10)
Computational efficiency. One important feature of the approximation in eq. 10 is that it can be computed in two steps. First the values V are multiplied by a prototypes-keys attention matrix S(PTK) ∈ RR×N , which can be much smaller than the full attention matrix S(QTK) ∈ RN×N (eq. 7), i.e., R N . Finally, this product is multiplied by a queries-prototypes attention matrix S(QTP) ∈ RN×R, which is also small. This allows us to sidestep the quadratic dependency of full attention over the input and output size (O(N2)), replacing it with linear complexity (O(N)) as long as R is kept constant.
Prototype selection. The aim for prototype-based attention approximation schemes is to use as few prototypes as possible while reconstructing the attention operation as accurately as possible. As such, it behooves us to select prototypes efficiently. We have two priorities for the prototypes: to dynamically adjust to the query and key vectors so that their region of space is well-reconstructed, and to minimize redundancy. The latter is important because the relative probability of a query–key pair may be over-estimated if many prototypes are clustered near that query and key. To address these criteria, we incrementally build a set of prototypes from the set of queries and keys such that a new prototype is maximally orthogonal to the prototypes already selected, starting with a query or key at random. This greedy strategy is dynamic, since it selects prototypes from the current set of queries and keys, and has high entropy, since it preferences well-separated prototypes. Moreover, it balances speed and performance by using a greedy strategy, rather than finding a globally-optimal solution to the maximum entropy sampling problem [61], making it suitable for use in a transformer.
Naïvely applying prototype-based attention approximation techniques to video transformers would involve creating a unique set of prototypes for each frame in the video. However, additional memory savings can be realized by sharing prototypes across time. Since there is significant information redundancy between frames, video data is opportune for compression via temporallyshared prototypes.
Orthoformer algorithm. The proposed approximation algorithm is outlined in Algorithm 1. The attention matrix is approximated using intermediate prototypes, selected as the most orthogonal subset of the queries and keys, given a desired number of prototypes R. To avoid a linear dependence on the sequence length N , we first randomly subsample cR queries and keys, for a constant c, before selecting the most orthogonal subset, resulting in a complexity quadratic in the number of prototypes O(R2). The algorithm then computes two attention matrices, much smaller than the original problem, and multiplies them with the values. The most related approach in the literature is Nyströmformer [85] attention, outlined in Algorithm 2. This approach involves a pseudoinverse to attenuate the effect of near-parallel prototypes, has more operations, and a greater memory footprint.
Algorithm 1 Orthoformer (proposed) attention 1: P← MostOrthogonalSubset(Q,K, R) 2: Ω1 = S(QTP/ √ D)
3: Ω2 = S(PTK/ √ D) 4: Y = Ω1(Ω2V)
Algorithm 2 Nyströmformer [85] attention 1: Pq,Pk ← SegmentMeans(Q,K, R) 2: Ω1 = S(QTPk/ √ D)
3: Ω−12 = IterativeInverse(S(PTqPk/ √ D), Niter) 4: Ω3 = S(PTqK/ √ D)
5: Y = Ω1 ( Ω−12 (Ω3V) )

heading: 3.3 The Motionformer model
text: Our full video transformer model builds on previous work, as shown in Table 1. In particular, we use the ViT image transformer model [20] as the base architecture, the separate space and time positional encodings of TimeSformer [8], and the cubic image tokenization strategy as in ViViT [3]. These design choices are ablated in Section 4. The crucial difference for our model is the trajectory attention mechanism, with which we demonstrate greater empirical performance than the other models.

heading: 4 Experiments
text: Datasets. Kinetics [36] is a large-scale video classification dataset consisting of short clips collected from YouTube, licensed by Google under Creative Commons. As it is a dataset of human actions, it potentially contains personally identifiable information such as faces, names and license plates. Something–Something V2 [26] is a video dataset containing more than 200,000 videos across 174 classes, with a greater emphasis on short temporal clips. In contrast to Kinetics, the background and objects remain consistent across different classes, and therefore models have to reason about fine-grained motion signals. We verified the importance of temporal reasoning on this dataset by showing that a single frame model gets significantly worse results, a decrease of 39% top-1 accuracy. In contrast, a drop of only 7% is seen on the Kinetics-400 dataset, showing that temporal information is much less relevant there. We obtained a research license for this data from https://20bn.com; the data was collected with consent. Epic Kitchens-100 [16] is an egocentric video dataset capturing daily kitchen activities. The highest scoring verb and action pair predicted by the network constitutes an action, for which we report top-1 accuracy. The data is licensed under Creative Commons and was collected with consent by the Epic Kitchens teams.
Implementation details. We follow a standard training and augmentation pipeline [3], as detailed in the appendix. For ablations, our default Motionformer model is the Vision Transformer Base architecture [20] (ViT/B), pretrained on ImageNet-21K [17], patch-size 2×16×16 with central frame initialization [3], separate space-time positional embedding and our trajectory attention. The base architecture has 12 layers, 12 attention heads, and an embedding dimension of 768. Our default Motionformer model operates on 16×224×224 videos with temporal stride 4 i.e. temporal extent of 2s. For comparisons with state-of-the-art, we report results on two additional variants: MotionformerHR, which has a high spatial resolution (16×336×336 videos with temporal stride 4 i.e. temporal extent of 2s), and Motionformer-L, which has a long temporal range (32×224×224 videos with temporal stride 3 i.e. temporal extent of 3s). Experiments with the large ViT architecture are deferred to the appendix.

heading: 4.1 Ablation studies
text: Input: tokenization. We consider the effect of different input tokenization approaches for both joint and trajectory attention on Kinetics-400 (K-400) and Something–Something V2 (SSv2) in Table 2b. For patch tokenization (1×16×16), we use inputs of size 8×224×224, while for cubic [3, 21] tokenization (2×16×16), we use inputs of size 16×224×224 to ensure that the model has the same number of input tokens over the same temporal range of 2 seconds. For both attention types, we see that cubic tokenization gives a 1% accuracy improvement over square tokenization on SSv2, a dataset for which temporal information is critical. Furthermore, our proposed trajectory attention using cubic tokenization outperforms joint space-time attention on both datasets.
Input: positional encoding. Here, we ablate using a joint or separate [21] (default) space-time positional encoding in Table 2b. Similar to the results for input tokenization, the choice of positional encoding is particularly important for the fine-grained motion dataset, SSv2. Since joint space-time attention treats tokens in the space-time volume equally, it benefits particularly from separating the positional encodings, allowing it to differentiate between space and time dimensions, with a 4% improvement on SSv2 over joint space-time encoding. Our proposed trajectory attention elicits a more modest improvement of 1% from using separated positional encodings on SSv2, and outperforms joint space-time attention in both settings on both datasets.
Attention block: comparisons. We compare our proposed trajectory attention to joint space-time attention [3], and divided space-time attention [8] in Table 4. Our trajectory attention (bottom row) outperforms both alternatives on the K-400 and SSv2 datasets. While we see only modest
improvements on the appearance cue-reliant K-400 dataset, our trajectory attention significantly outperforms (+2%) the other approaches on the motion cue-reliant SSv2 dataset. This dataset requires fine-grained motion understanding, something explicitly singled out by previous video transformer works [3, 8] as a challenge for their models. In contrast, our trajectory attention excels on this dataset, indicating that its motion-based design is able to capture some of this information.
Attention block: trajectory attention design. We ablate two design choices for our trajectory attention: the per-frame softmax normalization and the 1D temporal attention. Unlike joint space-time attention, which normalizes the attention map over all tokens in space and time, trajectory attention normalizes independently per frame, allowing us to implicitly track the trajectories of query patches in time. In row 5 of Table 4, we ablate the benefits of this design choice. We observe a reduction of 2.5% on K-400 and 5.6% on SSv2 by normalizing over space and time (NormST ) compared with normalizing over space alone (NormS). In row 4, we show the benefit of using 1D temporal attention (AttT ) to aggregate temporal features, compared to average pooling (AvgT ). We observe reductions of 3.7% on K-400 and 6.5% on SSv2 when using average pooling instead of temporal attention applied to the motion trajectories, although it saves computing the additional query/key/value projections.

heading: 4.2 Orthoformer approximated attention
text: Approximation comparisons. In Table 3a, we compare our Orthoformer algorithm to alternative strategies: Nyströmformer [85] and Performer [15]. Our algorithm performs comparably with Nyströmformer with a reduced memory footprint. In Table 5, we also compare these attention mechanisms on the Long Range Arena benchmark [69] to show applicability to other tasks and data types. Orthoformer is able to effectively approximate self-attention, outperforming the state-of-the-art despite using far fewer prototypes (64) and so gaining significant computational and memory benefits.
Prototype selection. A key part of our Orthoformer algorithm is the prototype selection procedure. In Table 3b, we ablate three prototype selection strategies: segment-means, random, and greedy most-orthogonal selection. Segment-means, the strategy used in Nyströmformer, performs poorly because it can generate multiple parallel prototypes, which will over-estimate the relative probability
of query–key pairs near those redundant prototypes. In contrast, our proposed strategy of selecting the most orthogonal prototypes from the query and key set works the best across both datasets, because it explicitly minimises prototype redundancy with respect to direction.
Number of prototypes. In Table 3c, we show that Orthoformer improves monotonically as the number of prototypes is increased. In particular, we see an average performance improvement of 4% on both datasets as we increase the number of prototypes from 16 to 128.
Temporally-shared prototypes. In Table 3d, we demonstrate the memory savings and performance benefits of sharing prototypes across time. On SSv2, we observe a 2% improvement in performance and a 5× decrease in memory usage. These gains may be attributed to the regularization effect of having prototypes leverage redundant information across frames.
Scaling transformer models with approximated trajectory attention. The Orthoformer attention approximation algorithm allows us to train larger models and higher resolution inputs for a given GPU memory budget. Here, we verify this, by training a large vision transformer model (ViT-L/16) [20] with a higher resolution input (336× 336 pixels) on the Kinetics-400 dataset, using the Orthoformer approximation with 196 temporally-shared prototypes and the same schedule as the base model. We use a fixed patch size (in pixels) for all models, and so the number of input tokens to the transformer scales with the square of the image resolution. As shown in Table 7, this model achieves a competitive accuracy without fine-tuning the training schedule, hyperparameters or data augmentation strategy. We expect that fine-tuning these on a validation set would greatly improve the model’s performance, based on results from contemporary work [3]. Obviously such a parameter sweep is more time-consuming for these large models, however, these preliminary results are indicative that higher accuracies are attainable if these parameters were to be optimized.

heading: 4.3 Comparison to the state-of-the-art
text: In Table 6, we compare our method against the current state-of-the-art on four common benchmarking datasets: Kinetics-400, Kinetics-600, Something–Something v2 and Epic-Kitchens. We find that our method performs favorably against current methods, even when compared against much larger models such as ViViT-L. In particular, it achieves strong top-1 accuracy improvements of 1.0% and 2.3% for SSv2 and Epic-Kitchen Nouns, respectively. These datasets require greater motion reasoning than Kinetics and so are a more challenging benchmark for video action recognition.

heading: 5 Conclusion
text: We have presented a new general-purpose attention block for video data that aggregates information along implicitly determined motion trajectories, lending a realistic inductive bias to the model. We further address its quadratic dependence on the input size with a new attention approximation
algorithm that significantly reduces the memory requirements, the largest bottleneck for transformer models. With these contributions, we obtain state-of-the-art results on several benchmark datasets. Nonetheless, our approach inherits many of the limitations of transformer models, including poor data efficiency and slow training. Specific to this work, trajectory attention has higher computational complexity than alternative attention operations used for video data. This is attenuated by the proposed approximation algorithm, with significantly reduced memory and computation requirements. However, its runtime is bottlenecked by prototype selection, which is not easily parallelized.
Future work. There are many applications of trajectory attention beyond video action classification, such as those tasks where temporal context is highly important. We see significant potential for using trajectory attention for tracking [28], temporal action localization [83, 81] and online action detection [86, 62], among other settings, and leave these as avenues for future work.
Potential negative societal impacts. One negative impact of this research is the significant environmental impact associated with training transformers, which are large and compute-expensive models. Compared to 3D-CNNs where the compute scales linearly with the sequence length, video transformers scale quadratically. To mitigate this, we proposed an approximation algorithm with linear complexity that greatly reduces the computational requirements. There is also potential for video action recognition models to be misused, such as for unauthorized surveillance.
Acknowledgments and Disclosure of Funding
We are grateful for support from the Rhodes Trust (M.P.), the European Research Council Starting Grant (IDIU 638009, D.C.), Qualcomm Innovation Fellowship (Y.A.), the Royal Academy of Engineering (RF201819/18/163, J.H.), and EPSRC Centre for Doctoral Training in Autonomous Intelligent Machines & Systems (EP/L015897/1, M.P. and Y.A.). Funding for M.P. was received under his Oxford affiliation. We thank Bernie Huang, Dong Guo, Rose Kanjirathinkal, Gedas Bertasius, Mike Zheng Shou, Mathilde Caron, Hugo Touvron, Benjamin Lefaudeux, Haoqi Fan, and Geoffrey Zweig from Facebook AI for their help, support, and discussion around this project. We also thank Max Bain and Tengda Han from VGG for fruitful discussions.

Review summaries:
The paper proposes a new component for transformer architectures to model trajectory attention by modeling temporal correspondences in dyanmic scenes. They also present approximation techniques to address computation and memory challenges for high-resolution videos. The proposed contributions are demonstrated on video action recognition tasks with SOTA results on multiple datasets. 

This work proposed a novel drop-in block for video transformers. Different from transformers that work on image or language modality, this block aggregates information along motion paths. The key idea is to design an efficient algorithm to approximation the path (trajectory attention), which requires quadratic dependence of computation and memory on the input size. As a solution, the proposed Motionformer model uses the (1) ViT image transformer model as the base architecture, (2) the separate space and time positional encodings of TimeSformer, (3) and the cubic image tokenization strategy as in ViViT. Experimental results on four video action recognition benchmarks show Motionformer can achieve state-of-the-art performance. 

The paper focused on model related motion information along the temporal domain. In particular, they proposed new drop-in block for video transformers that aggregates information along implicitly determined motion paths. The network is based on attentive mechanisms with Transformer. The new model doesn't rely on quadratic dependence of computation and memory on the input size, and is efficient to be applied to high resolution or long videos. The model was evaluated on multiple standard benchmarks, and it achieved convincing results.

The paper introduces a novel transformer architecture in which trajectories in video are considered. The model is able to leverage its own self-attention module to build trajectories around relevant objects in the video. Furthermore, authors introduce an approximation through a set of intermediate variables which enables them to reduce the computational cost of the transformer. Authors validate their model against state-of-the-art models in three main video benchmarks.