{'fraction_non_alphanumeric': 0.03460458374852795, 'fraction_numerical': 0.014448772533743999, 'mean_word_length': 4.8179183135704875, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Unified Recurrence Modeling for Video Action Anticipation

Forecasting future events based on evidence of current conditions is an innate skill of human beings, and key for predicting the outcome of any decision making. In artificial vision for example, we would like to predict the next human action before it happens, without observing the future video frames associated to it. Computer vision models for action anticipation are expected to collect the subtle evidence in the preamble of the target actions. In prior studies recurrence modeling often leads to better performance, the strong temporal inference is assumed to be a key element for reasonable prediction. To this end, we propose a unified recurrence modeling for video action anticipation via message passing framework. The information flow in space-time can be described by the interaction between vertices and edges, and the changes of vertices for each incoming frame reflects the underlying dynamics. Our model leverages self-attention as the building blocks for each of the message passing functions. In addition, we introduce different edge learning strategies that can be end-to-end optimized to gain better flexibility for the connectivity between vertices. Our experimental results demonstrate that our proposed method outperforms previous works on the large-scale EPIC-Kitchen dataset.


I. INTRODUCTION
Video action recognition is a long-standing problem in computer vision. The goal is to predict the action category that can be observed in a video clip, by recognizing the action discriminant spatio-temporal patterns and their context in the observations [1]. When it comes to action anticipation, however, a prediction must be made before the actual action is observed [2], [3], [4]. This is relevant for many real-world applications, for example, in assistive navigation systems [5], collaborative robotics [6], interactive entertainment [7], [8] and autonomous vehicles [9]. Figure 1 illustrates the definition of the video anticipation problem. Naively re-framing clip-based action recognition to perform anticipation is inadequate from a model design perspective, and may result in inefficiency.
Recurrent neural networks are widely adopted for modeling the temporal relationship in anticipation problems [3], [10], [11] and lead to better performance than clip-based methods [12], [13], as opposed to the mainstream in action recognition. The basic assumption is that in action anticipation the observations are incomplete and indirect, although related, to the target action. Some actions also come with misleading and unclear preamble information, for example, there are many future possibilities when observing someone extending its hand or moving closer to an area with many actionable objects in sight. Action anticipation is more towards forecasting than recognition, and thus the effectiveness of adapting action recognition models to the anticipation problem is reduced.
In this paper we present a unified recurrence modeling for video action anticipation which generalizes the recurrence mechanism by transferring the sequence learning into a graph representation learning realized via a message passing framework. We use self-attention as the universal building block for extracting information in vertices and edges. Vertices are associated to the representations provided by a backbone's specific receptive field. Edges describe the bonding strength between the vertices. Self-attention can be seen as the function of routing information between vertices. The attention weights are derived by the scaled dot-product, which computes the correlation of vertices, and can be interpreted as an implicit adjacency estimation. However, in this way, the representation of edges is limited and purely based on the similarity between vertices. To improve such trivial estimation, we propose edge learning strategies which explicitly approximate the edge connectivity. In the experimental results, we show that the proposed unified recurrent modeling outperforms several stateof-the-art methods on the large-scale egocentric video dataset EPIC-Kitchens. When combined with edge learning strategies, we obtain a further significant boost in performance.

A. Video Action Anticipation
Early works in video anticipation model the problem with recurrent neural networks [14], [15], [16]. Some prior works also leverage the future frames for learning the representations [17], [18]. A self-regulated learning framework for action anticipation on the egocentric video is presented in [10], which learns to emphasize the important context by its revision and reattend designs. RU-LSTM [19] deploys two LSTMs and behaves as an encoder-decoder, where the first progressively Fig. 1. Illustration of video action anticipation problem. The context of action may be different than the preamble of action. Models can only observe some frames before action actually starts ts, which is strictly ensured by an inaccessible "skip" period, and based on the evidence collected in the duration in ts − τa to predict the next action. The anticipation accuracy is measured at each different τa.
summarizes the observed together with the second that unrolls over future predictions without observing. The unrolling design can also be found in [11], [20], but with the rolling part replaced by SlowFast [21] and Higher-Order Recurrent Transformer, respectively. [22] aggregates the multiple predictions by pooling over different granularity of temporal segments to improve the anticipation accuracy. [23] combines causal selfattention with several regularization terms, showing the strong performance on the video anticipation problems. Our method also utilizes self-attention and unrolling designs. In addition, the proposed model learns how to propagate information in space-time via the generic message passing framework. All latent representations are further processed and contextualized with information from vertices and edges.

B. Message Passing Neural Network
The concept of message passing in neural networks is introduced in [24], where it was originally designed for molecular property prediction. It assumes an undirected graph structure with data-independent, equal edge contributions. To address this limitation, [25] deploys two encoders separately for vertex and edge estimation and aggregates them by an attention readout. Similar works also leverage attention or dedicated network design to learn the directed edge representations to improve the model capability [26], [27], [28]. Recently, [29] reinterpreted the Non-Local [30] and GAT [31] as a message passing functions and apply them to video understanding task. Differently, we view the message passing framework as the generalized recurrent models and specialize it for edge representations learning.

C. Self-Attention
[32] first proposed a recurrence-free sequence learning architecture by stacking several self-attention layers, which can achieve remarkable performance in the NLP domain. [33] demonstrates that self-attention can be treated as the recurrent unit which unfolds to input sequences to processes with shared weights. On the other hand, [34] proposes Vision Transformer (ViT), an architecture with only self-attention for image classification. ViT inherits the class-token design from [35] to better represent the prediction hypothesis. [36] further improves ViT by re-attending the multi-heads information in the post-softmax step to enable deeper configuration. Some recent studies explore ViT based models on video action recognition [37], [38], and also video anticipation [23]. Unlike these prior works, our proposed model processes the video in a flexible graph representation and leverages the message passing framework. Our model is lightweight and only contains a few self-attention layers which sequentially process each timestep.

III. METHOD
A. Backgrounds 1) Message Passing: Given an undirected graph G, the Message Passing algorithm involves a two-phase forwarding process. It is composed of (i) message passing phase with message function M and update function U ; and (ii) readout phase with readout function R. The message passing phase can be executed in an arbitrary number of T steps, where each time step learns to update the graph representation according to the following definition, where v is the vertices in G, and N (v) defines the neighbors of v. a vw is the connection strength bonding between vertex v and w. The readout phase then extracts the features of the whole graph produced in the message passing phase, at the final time step T ,ŷ Our method inherits these three core functions, i.e., message M , update U , and readout R. 2) Self-Attention: Self-Attention (SA) forms the Q, K, V tokens (for query, key, and value) from the input x. The output of attention is a weighted linear combination of values. Attention weights are computed by the scaled dot-product between query and key followed by a softmax, where scaling factor D is the input feature dimension, and W i Q , W i K , W i V are the trainable embeddings. We use superscript i to indicate that the embeddings are associated with each self-attention layer.
Multi-Head Self Attention (MHSA) performs n-way selfattention in parallel, where n is the total number of heads. An additional aggregation function, with parameters W agg , is adopted to fuse the information computed from each head, where [., .] presents concatenation.
Following the transformer-style architecture, a Feed-Forward Network (FFN) is introduced after each attention layer to project the attention output and bring the non-linearity. The FFN computes where σ can be any arbitrary nonlinear function.
B. Unified Recurrent Modeling 1) Self-Attention Block (SABlock): Following [39], as with many transformer-style architectures, we define our selfattention building block (SABlock) in prenorm style. It contains a Multi-Head Self-Attention (MHSA) followed by a FFN. Figure 2 left shows the SABlock design, We can optionally expose the edge information, in the form of the adjacency matrix A, into SABlock(.; A) by fusing A into the step after the softmax of scaled dot-product compu- tation. The extension can also be applied to M HSA(x; A). Accordingly, we rewrite (5) and (6) as Note that A is unique and shared in multi-heads self-attention.
2) Recurrent Cell: Figure 2 shows the design of the proposed architecture. Given the frame features x t at time t in shape (H, W , C), computed by a frame-level feature extractor, we compute the vertices e t v by a gated nonlinear transformation of x t . The vertex representations are reshaped into (HW , C), which presents the number of vertices HW and feature dimension C of each vertex. A position encoding W pe is added to e t v . We then leverage SABlock(.; A) with the adjacency matrix A for modeling each core function: message function, update function, and readout function.
The message function is a Multi-Layer Perceptron (MLP) with a self-gated design to form the vertex representations e t v . We concatenate the information coming from the previous h t−1 v with an additional linear transformation. The output is then processed by the self-attention block. Overall, Note that the linear transform, parameterized by W h and b h , reduces the feature size from 2C to C. The update function is another self-attention block that updates the graph representation from the message function with the vertices derived from the current frame, For better stability during the temporal propagation, the hyperbolic tangent (tanh) is applied to the computed graph representation from the update function, The readout function, which is also formed by self-attention, retrieves the layer output from the updated graph representation h t v , where W r and b r are the weights of a linear transformation that decodes the hidden representation, which is bounded to [-1, 1], into a more flexible value range. The output y t is then sent to a task-specific classifier. Our design translates the anticipation problem into a message passing scheme producing a graph-structured space-time representation. The connectivity of the graph structure is inferred from the input at each time step, as described next. The readout function is called when the prediction is required at any time t. The proposed model utilizes only multi-head self-attention for information routing between vertices. Note that the resulting spatial graph is either bi-directed, when an adjacency matrix A is provided, or else it is undirected.
Without any prior knowledge, we assume each vertex in the graph G is accessible by all other vertices (N (v) in (1) contains all vertices). In this case the scaled dot-product in the self-attention computes the pairwise similarity of all vertices from the inputs, which can be viewed as an implicit edge estimation. This can be extended by optionally providing the edge estimation explicitly, in the form of an adjacency matrix A = {a vw ; ∀w ∈ N (v), v ∈ G}, and using it during the attention computation as described in (11) and (12). We refer to these two cases as implicit and explicit edge learning.

C. Explicit Edge Learning
We propose two learning strategies to explicitly construct the edge information, as shown in Figure 3. Template Bank (TB) forms the estimation of edge connections by soft-fusing a set of learnable templates using weights computed from the frame input. Class Token Projection (CTP) performs the outerproduct of class tokens to construct the edge estimation, which are supervised from provided class labels. Both methods operate at frame-level at time t and approximate the corresponding edge estimation A t for the message function in (16).

1) Template bank (TB):
We introduce a template bank B of size S. Each template in the bank is of shape (N , N ) where N is the number of vertices in our graph. During the forward process, the adjacency matrix A t is formed by a weighted sum over the S templates. Template weights I are computed from an aggregated representation of frame inputs using a selector f select , consisting of a multi-layer perception (MLP), followed by softmax normalization, where e t v is the aggregated representation of the input obtained by average pooling of vertex information e t v .

2) Class Token Projection (CTP):
Leveraging the fact that the class tokens receive the supervision signal from groundtruth labeling, we can span the edge estimation by adopting the outer-product of class tokens projected into an embedding space. The learnable class tokens CLS t verb and CLS t noun represent the verb and noun hypothesis at time t, and have dimension (1, C). We project both class tokens individually by introducing two linear transforms that map each token into an embedding space whose dimension matches the number of vertices N . The outer-product of the projected token vectors then defines the adjacency matrix A t of shape (N , N ), where LN is the layer normalization, ⊗ is the outer-product operator, and W v , W n , b v , b n are the learnable weights of the projection functions. Note that with this definition, the class tokens are directly used in the self-attention computation of the readout function and in the task-specific classifier.

A. Datasets
We evaluate our methods on the EPIC-Kitchens-55 (EK55, [12]) dataset and its extension EPIC-Kitchens-100 (EK100, [45]). EK55 is a large scale egocentric video dataset with 55 hours of video recordings captured by 32 subjects in 32 kitchens. The data split for the action anticipation tasks is inherited from [19], containing 23492 segments for training and 4979 for validation. All combinations of 125 verbs and 352 nouns in the training split result in 2513 verb-noun action categories. EK100 extends EK55 to 100 hours of video recordings with revised annotations. The data split contains 67217 segments for training and 9668 for validation. EK100 considers 97 verbs and 300 nouns. Unique verb-noun pairs provide 3087 action categories.
We evaluate the predictive performance of our model for a range of anticipation intervals τ a , which indicate up to how many seconds before the action start time t s a model can access frames of the video recording.

B. Implementation Details
For our experiments with EK55 and EK100 we use the pretrained BN-Inception from [19] as a frame-level feature extractor. For sampling the dataset, we select a total of 14 observable frames for each segment with a fixed stride of α s = 0.25 (4 fps). All input frames are resized to 256x454 and fed to the proposed model. The output from the readout function is then mean-pooled and fed to an unrolling classifier to obtain verb, noun, and action predictions. The unrolling classifier is a widely adopted design in action anticipation [19], [11], [20], and we follow the similar classifier design as prior works. The classifier outputs are supervised with ground-truth labels using cross-entropy. We train the model by summing up cross-entropy from eight anticipation intervals, from τ a = 2.00 to τ a = 0.25 with step size 0.25. RandAugment [46] is used in all experiments. AdaBelief [47] in combination with the lookahead optimizer [48] is adopted. Weight decay is set to 0.001. Learning rate is initially set to 1e-4 and cosine annealed to 1e-7 on the last 25% of epochs. We use 4 × NVIDIA A100 40GB GPUs for training with batch size 32. We train for 50 epochs.
All the experiments are conducted on RGB-only modality. Table I shows the comparison of our proposed model and existing methods on EK55. We report accuracy for eight anticipation times τ a , from 2.00 to 0.25 seconds with step size 0.25. Some methods are constrained by its design, mostly clip based methods, to only being capable of providing the prediction at one pre-defined time step. Recurrent modeling has no such limitation, and also shows better performance: our proposed method using implicit edge estimation outperforms most of the current state-of-the-art methods. SF-RU ensembles with different sampling rates achieve higher top-5 action accuracy at τ a = 1, but not at τ a = 1.5 and τ a = 0.5 seconds. Using explicit edge learning strategies, Template Bank (TB) and Class-Token Projection (CTP), shows boosted accuracy at τ a = 1, and also brings significant improvement over mean top-5 action recalls. Table II includes the comparison to the previous winners of EPIC-Kitchens anticipation challenges. Top-1 and top-5 action accuracy at τ a = 1, which were used as evaluation criteria in the challenge, are reported. Under the same backbone usage, our method shows state-of-the-art performance on both top-1 and top-5 accuracy with explicit edge learning. AVT-h equipped with a strong backbone achieves a higher top-1 score but not in the top-5. EK100 evaluation by mean top-5 action accuracy is reported in Table III. Our method achieves overall better performance under the same backbone usage, and is slightly weaker but competitive when compared to AVT with a stronger AVT-b backbone.

C. Results
Overall, our proposed method shows state-of-the-art performance on both EK55 and EK100. Explicit edge learning with the template bank shows slightly better performance than the class-token projection approach on EK100. Classtoken projection, on the other hand, obtains better accuracy in different anticipation intervals on EK55. Table IV shows the experimental results on varying the bank sizes from 1 to 2048. In the case of bank size being equal to 1, a unique template is always selected globally across different timesteps. It can be viewed as placing a strong regularization to the intermediate graph representations, forcing the vertices to be connected in a specific way. When the bank size is larger than 1, the templates are no longer shared globally and become sample conditioned, which brings flexibility of message routing between vertices. According to the experiment results, when the bank size is greater than 64, top-1 / top-5 accuracy and mean recall improve over the configuration with a single global template. The reasonable choices are between 256 to 1024, with a peak performance at 512. No improvement is obtained with more than 1024 templates. Accordingly, we used bank size 512 throughout this study.

E. Design Variants in Class-Token Projection
We report on the performance of three Class-Token Projection variants. We modified (25) by using: (i) Global Token: P ⊗ P , where P is the projection of the global token used to    Table V, we conclude that using individual tokens for verbs and nouns consistently achieves better accuracy. We obtain similar performance by replacing the classifier inputs (mean-pooled over the vertices) with an additional action token. Based on the overall action accuracy, we used V, N tokens for projection in this study.

F. Parameters and Computation Counts
Our model implements message, update, and readout functions with only a multi-head self-attention (MHSA) followed by a feed-forward block (FFN). The total parameters in our model are about 21C 2 , around 21M when C=1024. The  template bank introduces additional 6.5M parameters for the selector and the stored templates. The class-token projection, on the other hand, introduces additional 0.23M parameters for class tokens and projections. The total computation, excluding backbone and classifier, is about 40 GFLOPs per timestep.

V. CONCLUSION
We presented a unified recurrent modeling which generalizes the recurrence mechanism by transferring the sequence into graph representation via message passing framework. We also propose novel edge learning strategies which explicitly approximate the edge connectivity of graph representation. On the large-scale egocentric EPIC-Kitchen dataset we outperform the current state-of-the-art in video action anticipation. The proposed model is generic, utilizes only self-attention, and hence provides a flexible framework that can be further extended. We plan to integrate multi-modality and explore the rich information in the annotations in future work.