A Hybrid RNN-HMM Approach for Weakly Supervised Temporal Action Segmentation

Action recognition has become a rapidly developing research field within the last decade. But with the increasing demand for large scale data, the need of hand annotated data for the training becomes more and more impractical. One way to avoid frame-based human annotation is the use of action order information to learn the respective action classes. In this context, we propose a hierarchical approach to address the problem of weakly supervised learning of human actions from ordered action labels by structuring recognition in a coarse-to-fine manner. Given a set of videos and an ordered list of the occurring actions, the task is to infer start and end frames of the related action classes within the video and to train the respective action classifiers without any need for hand labeled frame boundaries. We address this problem by combining a framewise RNN model with a coarse probabilistic inference. This combination allows for the temporal alignment of long sequences and thus, for an iterative training of both elements. While this system alone already generates good results, we show that the performance can be further improved by approximating the number of subactions to the characteristics of the different action classes as well as by the introduction of a regularizing length prior. The proposed system is evaluated on two benchmark datasets, the Breakfast and the Hollywood extended dataset, showing a competitive performance on various weak learning tasks such as temporal action segmentation and action alignment.


INTRODUCTION
A CTION recognition has been a vivid and productive field within the last decade.So far research in this area is mainly focused on fully supervised classification of short, pre-clipped video snippets as the progress on the major benchmarks in this field shows [1], [2], [3], [4], [5].But the collection of training data for such systems is usually a cost and time consuming process.Human annotators need to identify the specific classes in large video collections and manually mark the start and end frame of each corresponding action.This obviously makes it impractical to cover a larger amount of action classes and does not necessarily meet the preconditions of real live systems.This problem is further aggravated by the need for large scale training data for most deep learning approaches as shown by [5].Additionally the costs of training data collection make it hard to acquire enough data to advance concepts beyond short clips e.g.towards long term temporal models.
One way to address this issue is to give up on the need of frame-based annotation and to use only action labels and their ordering information to learn the respective action classes.This information is much easier to generate for human annotators, or can even be automatically derived from scripts [6], [7] or subtitles [8].First attempts to address this kind of problem have been made by [8], [9], [10], [11].
In this context, we propose a hierarchical approach to address the problem of weakly supervised learning of human actions from transcripts.The method combines recognition in a coarse-to-fine manner.On the fine grained level, we use a discriminative representation of subactions, modeled by a recurrent neural network as e.g.used by [12], [13], [14], [15].In our case, the RNN is used as basic recognition model as it provides robust classification of small temporal chunks.This allows to capture local temporal information.The RNN is supplemented by a coarse probabilistic model to allow for temporal alignment and inference over long sequences.
To bypass the difficulty of modeling long and complex action classes, we divide all actions into smaller building blocks.Those subactions are eventually modeled within the RNN and later combined by the inference process.The usage of subactions allows to distribute heterogeneous information of one action class over many subclasses and to capture characteristics such as the length of the overall action class.We show that automatically learning the number of subactions for each action class leads to a notable improved performance.
The obvious advantage of this kind of model is that it allows recognition of fine grained movements by still capturing mid and long temporal relations between frame responses.But the model is also especially suitable for the task of weak learning because it enforces a modular structure, as frame based responses are first combined to action classes and then to activity sequences.This allows for an iterative refinement of fine-grained and coarse recognition as well as an alternating adaptation of both elements.
Our model is trained with an iterative procedure.Given the weakly supervised training data, an initial segmentation is generated by uniformly distributing all actions among the video.For each action segment, all subactions are uniformly distributed among the part of the video belonging to the corresponding action.This way, an initial alignment between video frames and subactions is defined.In an iterative phase, the RNN is then trained on this alignment and used in combination with the coarse model to infer new action segment boundaries.From those boundaries, we recompute the number of subactions needed for each action class, distribute them again among the frames aligned to the respective action, and repeat the training process until convergence.
To further improve the performance in this context, we extend the standard HMM formulation by the introduction of a state length prior during inference.The length prior serves as an additional regulation to balance the temporal dynamic of the system.The intuition underlying this concept is that actions are usually not only characterized by their specific movements, but also by the duration that is necessary to execute a certain task.One way to include this characteristic in the proposed system is to model the length of an action by the number of HMM states used to represent the action.But we found that depending on the observation prior, a number of states will aggregate all frames of an action during inference, thus undermining the original idea of representing variable length actions by adapting the number of states only.Therefore, the proposed length prior serves as an additional regularization factor to enforce a meaningful length of the single states.We will show that the length prior helps to prevent degenerated states during inference and thus to improve recognition accuracy in general.
We evaluate our approach on two common benchmark datasets, the Breakfast dataset [16] and the Hollywood extended dataset [9], regarding two different tasks.The first task is temporal action segmentation, which refers to a combined segmentation and classification, where the test video is given without any further annotation.The second task is aligning a test video to a given order of actions, as proposed by Bojanowski et al. [9].
We regard those tasks with respect to different learning settings.First, in the weakly supervised scenario, we use only action labels and their ordering information to learn the respective action classes.Second, we extend the task to a semi supervised scenario by adding sparse frame-level annotation to the training data as shown in [10].In this case, which we refer to as semisupervised learning, a small fraction of the frames in the training set is annotated with the respective action class.It shows that, e.g. on Breakfast, using annotation of 0.25% of all frames (on average one annotated frame per action instance) is enough to improve the overall accuracy significantly.To put those findings into context, we further evaluate the proposed system for the case of fully supervised recognition of temporal sequences.It shows that the sparse supervision on frame level is able to reach results comparable to full supervision.Additionally, for all evaluated cases the system is able to outperform any other state-of-the-art approach so far.
A preliminary version of this work has been published in [17].This work extends the previous approach by two main contributions.First, we extend the proposed model by the motivation and introduction of a length model.We show how the length model helps to regularize the training and inference of the temporal model and that it outperforms the previous method as well as any other state-of-the-art approaches.We further modify the proposed training procedure to include sparse frame-level supervision to the system.This allows us to address the case of semi-supervised learning under sparse temporal supervision.Based on that, we not only show that the system is able to outperform any other system in this task, but we also demonstrate that the proposed length model helps not only for the case of weakly supervised learning, but also in case of semi-and fully supervised action recognition in general.

RELATED WORK
Action recognition has come a long way within the last years, moving forward from highly tuned hand-crafted features as proposed by Wang et al. [1], [18] towards learned features and temporal connections as e.g. proposed by Simonyan and Zisserman [19], Feichtenhofer et al. [20] and Wang et al. [4].Recent approaches show that results for classical action recognition are nearly ceiling on standard datasets [5], [21].Alternative approaches focus on the learning of temporal sequences without full supervision.In the following, we will first give an overview of concepts for weakly supervised learning from sequential data as well as weakly supervised fine-tuning with pretrained models.Finally, we will review different scenarios in the context of duration modeling for temporal sequences.

Weakly supervised learning from structured sequences
Compared to classical action recognition, the problem of weakly supervised learning of actions is a rather new topic.First works in this field, proposed by Laptev et al. [6] and Marszalek et al. [7], focus on mining training samples from movie scripts.They extract class samples based on the respective text passages and use those snippets for training without applying a dedicated temporal alignment of the action within the extracted clips.Attempts for learning action classes including temporal alignment on weakly annotated data are made by Duchenne et al. [22].Here, it is assumed that video clips contain only one class and the task is to temporally segment frames containing the relevant action from the background activities.The temporal alignment is thus interpreted as a binary clustering problem, separating temporal snippets containing the action class from the background segments.The clustering problem is formulated as a minimization of a discriminative cost function.This problem formulation is extended by Bojanowski et al. [9] also introducing the Hollywood extended dataset.The weak learning is formulated as a temporal assignment problem.Given a set of videos and the action order of each video, the task is to assign the respective class to each frame, thus to infer the respective action boundaries.The authors propose a discriminative clustering model using temporal ordering constraints to combine classification of each action and their temporal localization in each video clip.They propose the usage of the Frank-Wolfe algorithm to solve the convex minimization problem.This method has been adopted by Alayrac et al. [8] for unsupervised learning of task and story lines from instructional video.Another approach for weakly supervised learning from temporally ordered action lists is introduced by Huang et al. [10].Inspired by CTC models in speech recognition [23], they use extended connectionist temporal classification and introduce a visual similarity measures to prevent the CTC framework from degeneration and to enforce visually consistent paths.A different way, also lending on the concept of speech recognition, is proposed by Kuehne et al. [11].Here, actions are modeled by hidden Markov models (HMMs) with the aim to maximize the probability of training sequences being generated by the HMMs, by iteratively inferring the segmentation boundaries for each video and using the new segmentation to reestimate the model.The last two approaches were both evaluated on the Hollywood extended as well as on the Breakfast dataset, thus, these two datasets are also used for the evaluation of the proposed framework.Another idea is proposed by Ding and Xu [24] using a temporal convolutional feature pyramid network (TCFPN), an adaption of the encoder-decoder temporal convolutional neural networks (TCN) [25], for frame-wise classification in combination with an iterative soft boundary assignment for the action sequence alignment.During training, the alignment of the sequences to the transcripts is refined by an insertion strategy, which means that one class instance is represented by multiple successive instances of the same class, allowing the temporal receptive field of the TCN to extend in the temporal domain.

Weakly supervised fine-tuning
Other works focus on fine-tuning pretrained models by detecting actions in untrimmed videos.Here, usually pretrained networks are used to detect unseen actions in an untrimmed training set and networks are fine-tuned with respect to the detected instances.Note that classes in the datasets used for pretraining, such as UCF101 [26], Sports1M [27] or Kinetics [28], can overlap with the classes to search for in the untrimmed videos e.g. in case of the Thumos action detection task [29].There is further the information given, which classes appear in the untrimmed videos, but not when or how often they appear.This task was first addresses by Wang et al. [30] by selecting clip proposals from a set of untrimmed training videos to learn actions without exact boundary annotation.Nguyen et al. [31] propose a combination of attention weights and temporal class activation maps for the task.

Weakly supervised approaches in other domains
Koller et al. [32] integrate CNNs with hidden Markov models to learn sign language hand shapes based on a single frame CNN model from weakly annotated data.They extend the proposed single frame model by including LSTMs for temporal correlation in [33].A more speech related task is also proposed by Malmaud et al. [34], trying to align recipe steps to automatically generated speech transcripts from cooking videos.They use a hybrid HMM model in combination with a CNN based visual food detector to align a sequence of instructions, e.g. from textual recipes, to a video of someone carrying out a task.Gan et al. [35] learn action classes from web images and videos retrieved by specific search queries.They match images and video frames and use a regularization over the selected video frames to balance the matching procedure.[36] also takes weak video labels and noisy image labels as input and generates localized action frames as output.The localized action frames are used to train action recognition models.Yan et al. [37] use video-level tags for weakly-supervised actoraction segmentation using a multi-task ranking model to select representative supervoxels for actors and their respective actions.Finally, [38] propose an unsupervised technique to derive action classes from RGB-D videos using Gibbs sampling for learning long activities from basic action words.

Length modeling for temporal sequences
Bojanovski et al. [39] exploit a length model for weakly supervised video-to-text alignment.They regularize the length of the video segments that are supposed to be aligned with the respective description.Probably closest to the here proposed length prior is the work of Richard et al. [40], which introduces a length model that depends on the overall length of an action with respect to the mean length of the recognized class.This model is able to capture any discrete probability distribution and penalizes too short as well as too long sequences.The problem of this formulation is that the first-order dependence of the model leads to a quadratic runtime in the inference and therefore becomes unfeasible for longer temporal video data.The modeling of temporal duration has also a long tradition in the context of speech processing and has been used e.g. in [41].Since then it has been used in different contexts such as general modeling in case of explicit state duration HMMs [42] but also for speech synthesis [43] or the generation and decoding of temporal sequences, such as music [44].

Learning from transcripts only
In contrast to fully supervised action detection or segmentation approaches, where frame based annotation is available, weakly supervised learning is based on an ordered list of the actions occurring in the video.A video of the activity "Making tea" might consist of taking a cup, putting the teabag in it, and pouring water into the cup.In a fully supervised task, a temporal annotation of each action start and end time would be available for training, e.g. in form of 0 -21: take_cup 22 -68: add_teabag 69 -73: pour_water.
In our weakly supervised setup, all videos are just labeled with their ordered action sequence given as take_cup, add_teabag, pour_water.
As this information is available for each video and as long as all actions appear at least once in different contexts, it is possible to infer the related action boundaries without frame-based ground truth information, in our case by choosing the related action representation in a way that they maximize the probability that the sequences were generated by the respective models.
Note that this also formulates the necessary preconditions of the overall system, namely the fact that it needs the order of all actions as they appear in the sequences of the training set and that all actions need to appear at least with two different predecessors and successors.This constrain is necessary as we want to maximize the probability that the sequences of the training data are generated by models trained on a set of boundary assumptions.If e.g. two actions always occur together and in the same order, the combined probability for both models will be the same, no matter where a boundary point is set between those two actions.Only if one action appears in a different context, i.e. with different predecessors and successors, we are able to maximize the overall probability of the system with respect to different boundaries.

Learning from transcripts including sparse framelevel annotation
A slightly modified version of this problem is the learning from transcripts including sparse frame-level annotation.Here, again, the transcripts are provided as described, but additionally a fraction of the frames is also annotated with their respective ground truth label.This setting is motivated by the idea that single frame labels are usually easier to acquire than a full action segmentation.It requires only to look at a few frames without the need to watch the whole video.Such annotations can be collected e.g.via captcha tasks, Mechanical Turk or in similar settings.In this case, the annotation information for the video "Making tea" might look as follows take_cup, add_teabag, pour_water frame 3: take_cup frame 65: add_teabag.
The frame information does not refer to any action boundaries.It only indicates at which position in the video a certain action occurs.Thus, the task is still to infer the related action boundaries, but under the additional constraint of matching the annotated frames.

SYSTEM OVERVIEW
As sequential actions are naturally composed of hierarchical movements and actions at different levels of temporal granularity, we follow the idea of a hierarchical action model and adapt it for the case of weak learning of human actions in video data.
At top level, we model each temporal sequence as a combination of basic actions.This can be an activity, as e.g."Making tea" which would be made up of the actions "take cup", "add teabag" and "pour water".Each of those actions is represented by a respective probabilistic graph model, in this case an HMM, which models each action as a combination of subactions.Intuitively, the idea of subactions is based on the fact that, e.g. an action such as "take cup" consists of multiple movements like "move hand towards cup", "grab cup", "move cup towards body" and "release cup".
The proposed model captures those implicitly available but not explicitly annotated subactions as latent variables by the states in the graph.In order to build the state graph, it is not necessary to know the true number or label of the possible subactions.Instead, we set the number of subactions relative to the length of the corresponding action and update this factor as part of the training.Thus subactions at the beginning of an action capture motion patterns typical for that phase, as e.g. for "take cup" the first subactions comprise elements such as "move hand towards cup".To ensure the sequential peculiarity of human actions within the state graph, we use a feed-forward topology, allowing only self-transition or transitions to the next state.We also show that this characteristic can be further supported by introducing a state specific length model to regularize the duration of each state during inference.
In the following, we describe the proposed framework in detail, starting with the formal definition of the hierarchical action model.After that, we discuss the different elements of our model, the fine-graind subaction classification and the length prior in detail.Next, we describe the inference and training procedure for the weak as well as for the semi supervised case and close with a discussion of the chosen stop criterion.

Hierarchical action model
As already stated, our training data consists of a set of videos and their respective transcripts, indicating the occurring actions in the correct order.Formally, we can assume the training data is a set of tupels (x T 1 , a N 1 ), where x T 1 = (x 1 , . . ., x T ) are framewise features of a video with T frames and a N 1 is an ordered sequence (a 1 , . . ., a N ) of actions occurring in the video.The segmentation of the video is defined by the mapping that assigns an action segment index to each frame.Initially, this can simply be a linear segmentation of the provided actions, see Figure 5a.The likelihood of an action sequence x T 1 given the action transcripts a N 1 is then defined as where p(x t |a n(t) ) are probabilities of frame x t being generated by the action a n(t) .The action classes usually describe longer, task-oriented procedures that naturally consist of more than one significant movement and we want to efficiently capture those characteristics.We model each action as a sequential combination of subactions.For each action class a, a set of subactions s Ka is defined.The number K a is initially estimated by a heuristic and refined during the optimization process.Practically, this means that we subdivide the original long action classes into a set of smaller subactions.As subactions are obviously not defined by the given ordered action sequences, we treat them as latent variables that need to be learned by the model.In the following system description, we assume that the subaction frame boundaries are known, e.g. from previous iterations or from an initial uniform segmentation (see Figure 5b), and discuss the inference of concrete boundaries in Section 4. 3.
In order to combine the fine grained subactions to action sequences, a hidden Markov model H a for each action a is defined.The HMM ensures that subactions only occur in the correct ordering, i.e. that s be the known mapping from video frames to the subactions of the ordered action sequence a N 1 .This is basically the same mapping as the one in Equation ( 1) but on subaction level rather than on action level.When going from one frame to the next, we only allow to assign either the same subaction or the next subaction, so if at frame t the assigned subaction is i+1 .In the following, we will denote s(t) by the subscript s t for better readability.
The likelihood of an action sequence x T 1 given the action transcripts a N 1 is then given by where p(x t |s) are probabilities computed by the fine-grained subaction model, see Section 4.2.As defined by the feed forward model, the transition probabilities p(s t |s t−1 ) can model a selftransition or a transition from subaction s to subaction s.In both cases, we compute the relative frequencies of how often the transition s → s occurs by regarding the s t -mappings of all training videos.

Fine-grained Subaction Model
For the classification of fine-grained subactions, we use an RNN with a single hidden layer of gated recurrent units (GRUs) [45], a simplified version of LSTMs that shows comparable performance [46], [47] also in case of video classification [48], but has less parameters than an LSTM unit.The network is shown in Figure 1.For each frame, it predicts a probability distribution over all subactions, while the recurrent structure of the network allows to incorporate local temporal context.Since the RNN generates a posterior distribution p(s|x t ) but our coarse model deals with subaction-conditional probabilities, we use Bayes' rule to transform the network output to input: video x and thus allows for a direct usage of the distributions generated by the recurrent network in Equation ( 4).
As recurrent neural networks are usually trained using back propagation through time (BPTT) [49], which requires to process the whole sequence in a forward and backward pass and a video can be very long and may easily exceed 10, 000 frames, the computation time per minibatch can be extremely high.We therefore adapt the training procedure by using small chunks around each video frame.They can be efficiently processed with a reasonably large minibatch size in order to enable efficient RNN training on long videos.For each frame t, we create a chunk over x[t − 20, t] and forward it through the RNN.While this practically increases the amount of data that needs to be processed by a factor of 20, only short sequences need to be forwarded at once and we benefit from a high degree of parallelism and comparable large minibatch size.

Inference
To make use of the so far computed fine-grained subaction probabilities for long term recognition, we need to combine them over time to derive the underlying action classes as well as the overall temporal sequence.To do so, we use a temporal inference model, based on the hierarchical model formulation of our system.We will now discuss the inference on action and video level.Here different constraints can be applied.We first discuss the case of inference constrained by a grammar.Second, we consider the inference with given transcripts as a special case of a grammar with just one valid path.Third, we extend both modalities for sparse frame-level annotation.Adjusted boundaries Fig. 3. Boundary adjustment for semi-supervised training with sparse frame annotation.If the annotated frames are not consistent with the result after Viterbi decoding, the segmentation needs to be adjusted to fit the annotated frames.This also includes the association of the annotated frames to the respective segments.In this example, a(τ 2 ) and a(τ 3 ) both belong to the same class and could be associated to segment a 2 and a 4 .Using a dynamic warping approach, boundary shifts are chosen to be as small as possible.
Inference with grammar.Given a video x T 1 we want to find the most likely action sequence as well as the corresponding frame alignment.In order to limit the amount of action sequences to optimize over, a context-free grammar G is created by accumulating all action transcripts seen in the training data as in [11].Instead of finding the optimal action sequence directly, the inference can equivalently be performed over all possible frame-to-subaction alignments s t that are consistent with G. Consistent means that the unique action sequence defined by s t is generated by G.
To receive the respective action sequence âN 1 , we need to map the subaction output back to their original action classes.To this end, we define an extractor function A : s(t) → a N 1 that maps the frame-to-subaction alignment s t to its action sequence, see Figure 2 for an illustration.Then, Equation ( 6) can be rewritten as where L(G) is the set of all possible action sequences that can be generated by G. Equation ( 7) can be solved efficiently using a Viterbi algorithm if the grammar is context-free, see e.g.[50].Note that we have two types of transitions, namely transitions between subactions of the same class, i.e.A(s t−1 ) = A(s t ), as well as transitions between two action classes, i.e.A(s t−1 ) = A(s t ).The transition probability p(s t |s t−1 ) for two subactions of the same action class can be computed from the current alignment of the training data.As we use a feed-forward model, we only allow self-transitions, i.e. s t = s t−1 , or transitions to the next state.The probability p(s t |s t−1 ) is computed by counting the respective number of transitions for the given training alignment.The transition probability between actions is 1 if the transition encodes a viable path in the grammar and 0 if not.
Inference with transcripts.For training as well as for the task of aligning videos to a given ordered action sequence, the sequence of occurring actions a N 1 is already known and only the best frame alignment to a single sequence needs to be inferred.By defining a grammar that generates the given action sequence a N 1 only, this alignment task can be solved using Equation (7).
Inference with transcripts and sparse frame-level annotation.For the case that not only the transcripts but also sparse frame level annotation is available, the additional information is incorporated as additional guiding points, see Figure 3 for an illustration.The problem is that the guiding points only comprise the label for a specific frame, but do not include a matching of this frame to a certain segment in the transcripts.Thus, if the respective action occurs more than once, the frame can be assigned either way.To solve this assignment problem, we use a dynamic programming approach that assigns all labeled frames to their next matching action segment.We formulate a distance function of the inferred sequence a N 1 and an ordered set of F frame labels (τ, a(τ )) which consists of frames indices τ and the respective class label a(τ ).We further denote the respective start and end frame of the n-th segment of the Viterbi segmentation by start(a n ) and end(a n ).We assume that the respective segments have been found by the Viterbi algorithm as described before.The distance function between the current alignment and the sparse frame-level annotation is then given by i.e. if the annotated frame τ lies within the n-th inferred segment and has the same label, a(τ ) = a n , the distance is zero (e.g.a(τ 1 ) and a 1 in Figure 3).If the annotated frame lies outside segment n but has the same action label, the distance is the number of frames it needs to be moved to lie within the n-th segment (e.g.a(τ 2 ) and a 2 in Figure 3).If the annotated frame has another label than segment n, i.e. a(τ ) = a n , the distance is infinity (e.g.a(τ 2 ) and a 3 in Figure 3).We minimize the respective distance function over all annotations for each video: where F indicates the total number of framewise annotations.The minimization is reached by a dynamic warping approach.The resulting mapping n(τ ) from labeled frames to action segments provides the assignment between frame annotations and Viterbi segments that requires the boundaries to be moved as little as possible.
For all setups with sparse frame-level supervision, we follow a two step procedure.Given the training videos as well as the respective transcripts and labels, we first infer the best path based on the transcripts and in a second step align the resulting boundaries with the given labeled frames.

Length prior
We further add a state specific length prior as an additional regularization factor to our state model.The length prior serves in this case as a temporal decay model that rewards the model at the beginning of a new state to stay in this state for a certain amount of frames and punishes the model if it stays too long in the same state.The idea is motivated by the observation that, without length prior, the system tends to skip many states, only remaining Fig. 4. Example of state alignment for two instances of the same action as they are usually produced by the system without length prior and of an instance showing the intended state alignment.In the first two cases the HMM does not model the temporal progression, but rather uses the subaction states to distinguish between different action appearances.
in those states for one or two frames.An example of this behaviour is shown in Figure 4.It is clear to see that the HMMs in this case do not model any temporal progression.To evaluate this behaviour further, we counted the so called skip states, i.e. states which are only assigned to one frame, for the case without and with length prior.We observe that without length prior 74.6% of all processed states can be counted as skip states whereas the introduction of the length prior, e.g. for the best performing configuration reported in Section 6, reduces the amount of skip states to 61.9%.Formally, the length prior is a function of the duration of a state s at position t in the overall state-to-frame alignment, i.e. a function of the length l t (s t ) that captures how long the model already remained in one state at time t.The length function is defined recursively as The prior function p l t (s t )|s t models the decay factor based on the mean length len(s t ) of the respective state.The mean length is given by the average length of each state computed as len(s) = number of frames aligned to s number of s-instances .
An example for such a decay function can be a half Gaussian function defined as p l t (s t )|s t = e − (l t (s t )−µ) 2 σ 2 (12) with µ = 0 and σ = len(s t ), see Figure 8 and the Appendix for more decay functions.

Decoding with Length prior
The Viterbi decoding is a recursive function that computes the best path by maximizing the probability of all recent paths, encoded as a set of states, in combination with the probability of the current states.More formally, we define the recursive function Q to encode the maximum probability for a state path s at time t.In the following, we define s to be a possible predecessor state at time t − 1 and Q at (t − 1, s ) is the maximum probability of the HMM state path up to time t − 1.The value of Q at (t, s) is then computed by selecting the HMM state path up to time t that ends in state s that maximizes the probability over all predecessor paths multiplied by the current observation probability p(x t |s) and the transition probability from the previous to the current state p(s|s ).This recursive equation solves the maximization from Equation (7), Consequently, the overall best path by means of Equation ( 7) is the best path ending at time T , i.e. the path with the score max s Q(T, s), see also [51] for details.
We propose to use the length prior p l t (s t )|s t as a regularizer during the Viterbi decoding to prevent hypotheses that stay in the same HMM state for too long.To this end we add the length prior to the overall decoding formulation As the Viterbi decoding is carried out recursively, cf.Equation ( 13), the previously multiplied length factor needs to be replaced by the current length factor when going from frame t − 1 to frame t.Therefore the overall prior is defined as where we set p l t−1 (s t )|s t−1 = 1 if s t = s t−1 .
In order to incorporate a regularization on the length, we modify the recursive equation by multiplying the length prior, Note that the length prior here works differently from context dependent length models as e.g. proposed in [40].Such length models assume a first-order dependence on the ending times of the single states.Including such a length model might allow for an even more precise length modeling but would require the Viterbi decoding to run not only over all time frames but also over all possible lengths, which would increase the runtime from linear in the frames, i.e.O(T ), to quadratic in the frames, i.e.O(T 2 ).Since videos are usually long (T 1000), this quickly becomes infeasible to compute.
The main advantage of the here proposed length prior is that it only depends on the current length l t (s t ), which is also recursively defined and keeps the overall runtime linear.This formulation requires the length prior to be a monotonically decreasing function.Consider a path that, at time t, has just changed to state s.A non-monotonous function such as a classical Poisson distribution would penalize such a path strongly, although the path may turn out very good if it stays in state s in the future.Using monotonous length priors avoids this problem and only paths that are in a certain state s for too long are penalized.We define functions such as a half Poisson, where the probability is constant up to the peak of the original Poisson distribution and then decreases as usual.Similarly, we propose a half Gaussian that is centered at zero and decreases as the length increases like a Gaussian distribution, see Figure 8 and the Appendix for details.
We evaluate the four different models, namely a box function, a linear decreasing function, a half Poisson, and a half Gaussian distribution in Section 6.3.

Training
The training of the model is done iteratively, altering between the recurrent neural network and the hidden Markov model training, and the alignment of frames to subactions via the hidden Markov model.The whole process is illustrated in Figure 5.We start with a linear segmentation and alignment of all training videos, train the respective RNN and HMM models and run an inference with the trained models which results in new frame boundaries for each action.We then redistribute the HMM states according to the new segmentation and repeat the training procedure several times until convergence is reached.In the following, we describe the two relevant steps, the initialization as well as the iterative training procedure in detail.
Initialization Each video is divided into N segments of equal size, where N is the number of action instances in the transcript (Figure 5a).Each action segment is further subdivided equally across the subactions (Figure 5b).Note that this defines the mapping s(t) from frames to subactions.Additionally, each subaction should cover m frames of an action on average.We fix m to 10 frames per subaction.Thus, the initial number of subactions for each action is number of frames number of action instances • m .
Hence, initially each action is modeled with the same number of subactions.This can change during the following iterative optimization.
Training The fine-grained RNN and the HMM are trained with the current mapping s t as ground truth (Figure 5c).Then, the RNN and HMM are applied to the training videos and a new alignment of frames to subactions (Figure 5d) is inferred given the new fine-grained probabilities p(x t |s) from the RNN.The new alignment is obtained by finding the subaction mapping s t that best explains the data: Again, Equation ( 18) can be efficiently computed using a Viterbi algorithm and we include our proposed length regularization in the recursive equation, cf.Equation ( 16).For the case of training with sparse frame-level annotations, the resulting alignment is further refined as described in Section 4.3.
Reestimation.Once the realignment is computed for all training videos, the new average length of each action is computed and the number of subactions is re-estimated based on the updated average action lengths, which is computed as Equation ( 17), but for the entire action a instead of the state s.Correspondingly, there are now len(a)/m subactions for action a, which are again uniformly distributed among the frames assigned to the action (Figure 5e).This new alignment is then used as current mapping and, as described in the beginning, the RNN can be trained with    Training process of our model.Initially, each action is modeled with the same number of subactions and the video is linearly aligned to these subactions.Based on this alignment, the RNN is trained and used in combination with the HMMs to realign the video frames to the subactions.Eventually, the number of subactions per action is reestimated and the process is iterated until convergence.
this new mapping and the HMM parameters can be updated (Figure 5f).As the mapping for each iteration requires a different number of outputs for the RNN, we train a new RNN-model for each iteration from scratch, initialized with random weights.These steps are iterated until convergence.

Stop criterion
As the system iteratively approximates the optimal action segmentation on the training data, we define a stop criterion based on the overall amount of frame labels changed from one iteration to the succeeding one.Overall we stop if less than 5% of the frames are assigned a new label or we reach a maximum of 15 iterations.

Datasets
We evaluate the proposed approach on two different datasets.The Breakfast dataset is a large scale dataset for hierarchical activity recognition and detection and comprises roughly about 4 million frames in 1, 712 clips and has an overall duration of 66.7 hours.The dataset comprises 10 breakfast related tasks such as making tea but also complex activities such as the preparation of fried egg or pancake recorded with 52 different test persons in various kitchen environments.It features 48 action classes with a mean of 4.9 instances per video.We follow the evaluation protocol as proposed by the authors in [16].The Hollywood extended [9] dataset is an extension of the well known Hollywood dataset, featuring 937 clips from different Hollywood movies with overall 787, 720 frames.The clips are annotated with two or more action labels resulting in 16 different action classes overall and a mean of 2.5 action instances per clip.The authors propose a ten fold evaluation by selecting random clips.To allow for a better reproducibility of the results, we choose the last digit of the video number to define the splitting in the following evaluation.
Both datasets show a high heterogeneity, the first because of different persons, locations and camera viewpoints, the second because of the naturally high appearance variation of the movie sources.The two datasets differ in the mean and variance of the video length as well as in the duration and variance of the annotated actions.This difference is important as it can be expected that modifications of the temporal modeling have a higher impact on data with higher temporal heterogeneity than on those with homogeneous temporal properties.

Features
For both datasets we computed the features as described in [52] using improved dense trajectories (IDT) and Fisher vectors (FVs).For the FV representation, we first reduce the dimensionality of the IDT features from 426 to 64 by PCA and sample 150, 000 randomly selected features to build a GMM with 64 Gaussians.The Fisher vector representation [53] for each frame is computed over a sliding window of 20 frames.Following [54], we apply power-and 2 -normalization to the resulting FV representation.Additionally, we reduce the final FV representation from 8, 192 to 64 dimensions via PCA to keep the overall video representation manageable and easier to process.

Alignment vs. Segmentation
In case of weak learning of human actions two possible tasks can be considered to assess the accuracy of the proposed system, alignment and segmentation.In case of temporal action alignment as e.g.used by [9], [10], [11], the test video and its respective transcript annotation is given and the task is to infer the segment boundaries based on the given order information.The accuracy in this case can be reported by mean over frames (MoF) as proposed by [11] or by the Jaccard index (Jacc.),as in [9].In this case, the Jaccard index is computed as intersection over detection (IoD)  and defined by |G ∩ D|/|D| with G referring to the ground truth frames and D referring to the detected action frames.
In case of temporal action segmentation, only the test video is given and the task is to infer the occurring actions as well as their respective frame boundaries.We refer to temporal action segmentation as the combined video segmentation and classification.Thus, given a video without any further information, the task is to classify all frames according to their related action.This includes to infer which actions occur in the video, in which order they occur, and their respective start and end frames.This task is evaluated by the mean over frames (MoF) [10], [11].

EVALUATION
We first evaluate the performance of the different components of our system, namely the GRU based classification, the subaction modeling, the length prior, and the semi-supervised setup for temporal action segmentation.We evaluate all tasks on the test set of the Breakfast dataset and report results as mean accuracy over frames (MoF).We iterate the system until the stop criterion as described in Section 4.7 is reached.

Evaluation of GRU-based model
First, we evaluate the influence of the proposed fine grained RNN modeling.In order to analyze the capability of capturing temporal context with the recurrent network, we compare it to a system where a multilayer perceptron (MLP) is used instead.The MLP only operates on frame level and does not capture temporal context as there is no recurrent connection involved.In order to provide a fair comparison to the recurrent model, we setup the MLP with a single hidden layer of rectified units such that it has the same number of parameters as the recurrent network.We also look at the performance of standard GMM models, as they would be usually used in the context of HMMs.In this case, we follow the setup as described by [52], using a single Gaussian distribution for each state of the model.
For this evaluation, we use a simplified version of the system without subaction reestimation or length prior to achieve comparable results after each iteration.We show results for the first five iterations in Table 1.It becomes clear that GRUs outperform MLPs and GMMs, starting with 25.5% for the initial recognition, and reaching up to 29.3% after the fourth iteration.The MLP baseline stays continuously below this performance.Thus, it can be assumed that the additional information gained by recurrent connections in this context supports classification.One can further see that the MLP reaches its best performance after the second iteration and then continuously decreases, whereas the GRU begins to oscillate around 29%, hinting that the MLP also starts to overfit at an earlier stage compared to the GRU.The GMMs are also

TABLE 2
Results for temporal action segmentation on the Breakfast dataset comparing accuracy of the proposed system (GRU + reestimation) to the accuracy of the same architecture without subactions (GRU no subactions) and to the architecture with subclasses but without reestimation.
performing better than the MLP but, with a maximum of 27.0%, do not reach the performance of the GRU.

Analysis of the subaction modeling
Second, we regard the properties of the proposed subaction modeling.We therefore compare the proposed system with the results of the same setting, but without further subdividing actions into subactions (GRU no subactions, Table 2).Additionally, we regard results of the system without reestimation of subactions during optimization (GRU w/o reestimation, Table 2).For the system without reestimation, we follow the initial steps as shown in Figure 5, thus, we linearly segment the videos according to the number of actions, generate an initial subaction alignment, train the respective subaction classes, and realign the sequence based on the RNN output.But, opposed to the setup with reestimation, we omit the step of reestimating the number of subclasses and the following alignment.Instead, we just use the output of the realignment (see Figure 5d) to retrain the classifier and iterate the process of training, alignment, and re-training.Thus, the number of subclasses is constant and the coarse model is not adapted to the overall estimated length of the action class.Finally, we compare to an approach in which we use the ground truth boundaries to compute the mean length of an action class and set the number of subactions based on the mean ground truth length (GRU + GT length, Table 2).Here, all action classes are still uniformly initialized, but longer action classes are divided into more subactions than shorter ones.We include this scenario as it models the performance in case that the optimal number of subaction classes would be found.We again use a simplified version of the system without length prior to achieve comparable results.
Table 2 shows that the performance without subactions is significantly below all other configurations, supporting the idea that subaction modeling in general helps recognition in this scenario.The model with subactions, but without reestimation, improves over the single class model, but is still below the system with subaction reestimation.Compared to that, the model with subaction reestimation performs 5% better.We ascribe the performance increase of the reestimated model to the fact that a good performance is highly related to the correct number of subactions, thus to a good length representation of the single actions.The impact of the number of subactions becomes clear, when considering the results when the ground truth action lengths are used.The performance of the same system, just with different numbers of subactions, increases by almost 20%.This effect becomes also visible in the qualitative results as shown in Figure 6.Comparing the results of the three configurations -without GRU no subaction: GRU w/o reest.: GRU with reest.: Ground truth: sequence: take bowl, pour cereals, pour milk, stir cereals GRU no subaction: GRU w/o reest.: GRU with reest.: Ground truth: sequence: pour oil, crack egg, fry egg, add saltnpepper, fry egg, put egg2plate Fig. 6.Example of temporal action segmentation for two samples from the Breakfast dataset showing the segmentation result for "preparing cereals" and "preparing friedegg".Although the actions are not always correctly detected, there is still a reasonable alignment of detected actions and ground truth boundaries.subactions, without restimation, and with reestimation -to the ground truth annotations, it shows that, although the overall sequence is not always correctly inferred by the models, the system with reestimation finds a good alignment compared to the ground truth frame boundaries.We also regard how the overall number of subactions changes by reestimating after each iteration as shown in Figure 7.It becomes visible that the number of subactions mainly increases in the beginning and starts to converge after five to ten iterations.approximated.ground truth distribution by XX% percent, w as the the state distribution of the reestimated model e.g. after iteration eight deviates only by XX%.

Analysis of length prior
In a next step, we analyze the impact of the length prior on the overall system.In terms of decay functions, we evaluate four different types of functions as shown in Figure 8, a simple box function, a linear decay function, a half Poisson decay and a half Gaussian function.First, we evaluate the overall performance of the different functions on the system.For all measures, we use the stop criterion as described in Section 4.7.As Table 3 shows, the length model mainly improves the results for the Breakfast dataset.All length models are doing better than the original system without length model in this case, with a best accuracy of 37.0% reached by the linear decay function.This is further supported by the evaluation of the performance during training as the plot in Figure 9 shows.Here, the solid line shows the segmentation accuracy of the models after each iteration until the stop criterion is reached.After that, additional results are displayed by a dashed line.It shows that all four functions significantly outperform the system without length prior with best results at 36.7% for box and 35.7% and 36.7% for half Poisson and Gaussian.
The impact of the length models on the Hollywood Extended dataset is smaller than on the Breakfast dataset as shown in Table 3.This behaviour can be based on the fact that the actions in the Hollywood Extended dataset are usually shorter and the action classes have a lower temporal variance compared to the Breakfast dataset.On Hollywood extended, all action classes usually have a consistent mean frame length, where as in case of Breakfast, the mean length of action classes significantly varies.Thus, the benefit of using length models increases with the heterogeneity of the target action classes.Therefore it can be expected that a length model has less impact in this case than for datasets with high temporal variance among the action classes.
Overall, based on the numbers in Table 3, it can be stated that the half Gaussian function gives the most consistent improvement for both datasets.We therefore use a length prior with a half Gaussian function for the following experiments.

Semi supervised learning including sparse framelevel annotation
Finally, we evaluate the behaviour of the proposed system in a semi-supervised setup including sparse frame-based annotation.We follow the idea presented in [10] of using a fraction of all frames as additional information during training.We again report all results for the segmentation task on the Breakfast dataset.We start with a fraction of 0.25% of all annotated frames which roughly corresponds to one frame per action instance in the dataset.We uniformly select the frame annotation from the ground truth dataset.Note that not all action instances will have a respectively labeled frame and we do not get any information about the segment boundaries by this type of labeling.
Results for the sparse frame-level annotation are shown in Table 4.It shows that even a small fraction of annotated frames (0.25%) helps to improve the overall accuracy on the Breakfast dataset by almost 20% reaching 56.0%.It further shows that with only 1% of annotated frames, the result is already getting close to the fully supervised setting of 61.0%.Additionally, we  observe a faster convergence behaviour when including more frame-level annotation.The system without frame-level annotation usually needs 12-15 iterations to meet the respective convergence criterion.As can be seen in Figure 10 in case of frame level supervision, we reach convergence already after two to four iteration steps, as the overall frame alignment obviously shifts less the more frame information is available.This supports the idea that a partial annotation of frames might be a valid alternative to the time consuming, fully supervised labeling.
The same behaviour at a smaller scale is also visible for the Hollywood Extended dataset (see Table 4).Here, we mainly see an increase when 1% or more frames are annotated.It can be assumed that the smaller improvement is based on two points.First, the weakly supervised accuracy of 12.3% of the Hollywood Extended dataset is already close to the fully supervised setting with 13.7%.Thus, the increase can only be within this margin.Second, we again observe that the additional information during training mainly helps for a better temporal alignment of the data.Thus, it can be expected that the influence on datasets with higher temporal variance is stronger than for those with lower temporal variance.

Comparison to State-of-the-Art
Temporal Action Segmentation We compare our system to four different approaches published for this task: The first is the Ordered Constrained Discriminative Clustering (OCDC) proposed by Bojanovski et al. [9], which has been introduced on the Hollywood extended dataset.Second, we compare against the HTK system used by Kuehne et al. [11], third against the Extended Connectionist Temporal Classification (ECTC) by Huang et al. [10] and fourth against the temporal convolutional feature pyramid network (TCFPN) by Ding and Xu [24].We further compare against a previous version of this system without lenght model [17].
For the Breakfast dataset, we follow the evaluation protocol of [16] and [10] and report results as mean accuracy over frames over four splits.For the Hollywood Extended dataset, we follow the evaluation protocol of [11] and report the Jaccard index (Jacc.)as intersection over union (IoU) over 10 splits.
Results are shown in Table 5.One can see that both GRU   we report performance as mean over frames (Mof), for Hollywood extended, we measure the Jaccard index as intersection over union for this task (*from [10]).
systems show a good performance, and that the proposed system outperforms most current approaches on the evaluated datasets.
Only the recently released TCFPN reaches better results on this task.
Temporal Action Alignment We also address the task of action alignment.We assume that given a video and a sequence of temporally ordered actions, the task is to infer the respective boundaries for the given action order.We report results for the test set of Breakfast as well as for the Hollywood Extended dataset based on the Jaccard index (Jacc.)computed as intersection over detection (IoD) as proposed by [9].The results are shown in Table 6.
The proposed approach outperforms current state-of-the-art approaches.It also shows that the system without length model performs slightly better than the system with length model for the alignment in case of Hollywood Extended.As already discussed in Section 6.3, the differences between the proposed approach with and without length model are marginal on this dataset.Fully supervised classification We finally evaluate the approach in a fully supervised setting and compare it to other proposed approaches.Here, we compute the mean length from the training annotations directly and use it to determine the number of states

GRU-RNN
Table 7 shows that the system clearly outperforms previous approaches.Since the apporaches [16] and [52] have a similar hierarchical structure as the presented system and similar features [52], we can assume that the main improvement can be attributed to the underlying GRU models.This is consistent with the findings in Section 6.1, where it shows that the proposed GRUs improve fine-grained frame-based classification compared to other approaches.Additionally, it shows that the length model also improves the segmentation accuracy in case of fully supervised training.This is important as in this case, we can assume that all other temporal factors, such as the number of states are already optimal.Thus, even in this case, a temporal prior can improve the overall recognition of the system.

CONCLUSION
We presented an approach for weakly, semi and fully supervised learning of human actions based on a combination of a discriminative representation of subactions modeled by a recurrent neural network and a coarse probabilistic model to allow for a temporal alignment and inference over long sequences.Although the system itself shows already good results, the performance is significantly improved by approximating the number of subactions for the different action classes and by adding a length prior formulation to the overall system.Accordingly, we combine the length model with the adaptation of the number of subaction classes by iterating realignment and reestimation during training.The resulting model shows a competitive performance on various weak learning tasks such as temporal action segmentation and action alignment on two standard benchmark datasets.
Linear Alignment to Actions (b) Linear Alignment to HMM States s

Fig. 5 .
Fig.5.Training process of our model.Initially, each action is modeled with the same number of subactions and the video is linearly aligned to these subactions.Based on this alignment, the RNN is trained and used in combination with the HMMs to realign the video frames to the subactions.Eventually, the number of subactions per action is reestimated and the process is iterated until convergence.

Fig. 8 .
Fig. 8. Overview of evaluated length models showing a simple box function, a linear decay function, a half Poisson decay and a half Gaussian function for a subaction with a mean length of 10 frames.See Appendix for formulas of the functions.

Fig. 9 .
Fig. 9. Results for temporal segmentation with different length models on the Breakfast dataset over 15 iterations.Solid lines show the results until the proposed stop criterion is reached.Dashed lines show the results after the stop criterion.

Fig. 10 .
Fig.10.Results of temporal action segmentation with semi supervised training on the Breakfast dataset for 10 iterations.Solid lines show the results until the proposed stop criterion is reached, dashed lines show the results after the stop criterion.It shows that even small fractions of annotated frames can significantly improve the overall performance of the system.
Estimate p(x t |s t ) and p(s t |s t−1 ) t |s t ) • p(s t |s t−1 ) • p(l t (s t )|s t Estimate p(x t |s t ) and p(s t |s t−1 )

TABLE 1
Results for temporal action segmentation with GRU-based model compared to MLP-based model and GMM over five iterations.It shows that the MLP and GMM are outperformed by the GRU-based model.Additionally the MLP-based model quickly starts to overfit whereas the GRU oscillates at a constant higher level.
Fig. 7. Evolution of number of states for the model with state reestimation.The number of states increases in the first five iterations and converges after ten iterations.

TABLE 4
Results for temporal action segmentation wtih semi supervised learning on the Breakfast and the Hollywood Extended dataset with a half Gaussian length prior.The fraction indicates how many frames of the data were labeled.A fraction of 1 corresponds to a fully supervised setup.All results are based on the stop criterion of 5% frame change rate during alignment or a maximum of 15 iterations.

TABLE 5
Comparison of temporal action segmentation performance for GRU based weak learning with other approaches.For the Breakfast dataset,

TABLE 6
Results for temporal action alignment on the test set of the Breakfast and the Hollywood extended dataset reported as Jaccard index of intersection over detection (IoD)(**results obtained from the authors).

TABLE 7
Results for fully supervised temporal action segmentation on the Breakfast dataset (MoF).