{'fraction_non_alphanumeric': 0.03299627461415647, 'fraction_numerical': 0.012240553485896753, 'mean_word_length': 4.4810403500243075, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Encoding Video and Label Priors for Multi-label Video Classification on YouTube-8M dataset

YouTube-8M is the largest video dataset for multi-label video classification. In order to tackle the multi-label classification on this challenging dataset, it is necessary to solve several issues such as temporal modeling of videos, label imbalances, and correlations between labels. We develop a deep neural network model, which consists of four components: the frame encoder, the classification layer, the label processing layer, and the loss function. We introduce our newly proposed methods and discusses how existing models operate in the YouTube-8M Classification Task, what insights they have, and why they succeed (or fail) to achieve good performance. Most of the models we proposed are very high compared to the baseline models, and the ensemble of the models we used is 8th in the Kaggle Competition.


Introduction
Many challenging problems have been studied in computer vision research toward video understanding, such as video classification [9,13], video captioning [19,20], video QA [21], and MovieQA [16], to name a few. YouTube-8M [1] is the largest video dataset for multi-label video classification. Its main problem is to predict the most relevant labels for a given video out of 4,716 predefined classes. Therefore, it requires jointly solving two important problems; video classification and multi-label classification.
From the view of the video classification, YouTube-8M is challenging in that it covers more general classes like soccer, game, vehicle, and food, while existing video classification datasets focus on more specific class groups, such as sports in Sports-1M [9], and actions in UCF-101 [13]. Therefore, unlike the importance of modeling motion fea-tures in UCF-101 [13] or Sports-1M [9], it is important to capture more generic video information(e.g. temporal encoding method for video, audio feature modeling) in YouTube-8M.
From the view of multi-label classification, the key issues to solve in YouTube-8M are label imbalances and correlations between labels. YouTube-8M involves 4,716 class labels, and the number of videos belonging to each class is significantly different, which causes a label imbalance issue that the classifier fits to the biased data. At the same time, many classes are closely related one another, such as {Football, Kick, Penalty kick, Indoor soccer} or {Super Mario Bros, Super Mario World, Super Mario bros 3, Mario Kart, Mario Kart 8}. It is also challenging to resolve the correlations between labels to decide final prediction.
Based on the challenges of the multi-label video classification task on YouTube-8M described the above, we focus on addressing i) temporal encoding for video, ii) relieving the label imbalance problem, and iii) utilizing the correlated label information. Our model consists of four components: i) video pooling layer, ii) classification layer, iii) label processing layer, and iv) loss function. The proposed components indeed show significant performance improvement over the baseline models of YouTube-8M [1], and finally our ensemble model is ranked 8th in the Google Cloud & YouTube-8M Video Understanding Challenge 1 . Figure 1 shows the overall pipeline of our model. We first present video features we used, and then explain its four key components in the following sections. The input of the model concatenates the frame feature I f and audio feature I a , which is denoted by I. We divided the model into four components (Video Pooling Layer, Classification Layer, Label Processing Layer, Loss Function) and experimented with the newly proposed model or variants of previously proposed model in each component. Each of the four components is denoted by (g θ , h θ , C θ , L), and each output of first 3 layer is denoted by (Og, O h , Oc).

Video Features
The inputs of the model are frame features and audio features of a video clip. The frame features are obtained by sampling a clip at 1-second interval, and extracting 2,048dimensional vector from every frame through Inception-V3 Network [15] pretrained to ImageNet [4]. Then the feature is reduced to an 1,024-dimension via PCA (+ whitening), then quantized, and finally L2-normalized. As a result, for a video of T seconds long, its frame is I f ∈ R T ×1,024 . The audio features re extracted using the VGG-inspired acoustic model [6] followed by L2-normalization, which is denoted by I a ∈ R T ×128 .
As the input of our model, we concatenate the frame feature I f and the audio feature I a at every time step, denoted by I ∈ R T ×1,152 . We test the compact bilinear pooling [5] with various dimensions between I f and I a , but all of them have significantly lower performance than the simple concatenation. From now on, we use I to denote the input features of a video over all frames, and I t ∈ R 1,152 as t-th frame vector.

Video Pooling Layer
The Video Pooling Layer g θ : R T ×1,152 → R d is defined as a parametric function that encodes a sequence of T feature vectors I into a d-dimensional embedding vector. We test five different encoding structures as follows.

A Variant of LSTM
The Long Short Term Memory (LSTM) model [7] is one of the most popular frameworks for modeling sequence data. We use a variant of the LSTM as follows: (1) where t denotes each time step, i, f , o are the input, forget, output gate, c t , s t are long-term and short-term memory respectively.
The baseline model uses only the final hidden states of the LSTM (i.e. c T , s T ), but we additionally exploit the following two states in order to extract as much information as possible from the LSTM: i) the state M l = a (2 × d)-dimensional vector, whereas our model that additionally uses M l and O l has the output of a (4 × d)dimensional vector. Experimentally, we choose the LSTM cell size d = 1,152. We also apply the layer normalization [2] to each layer of the LSTM for fast convergence, and also use the dropout with dropout rate=0.8 to increase the generalization capacity.

CNNs
Convolutional neural networks (CNNs) are often used to jointly capture spatial information from images or video in many computer vision tasks. That is, the convolution kernels generate output signals considering all the elements in the window together, and thus they effectively work with spatially or temporally sequential information (e.g. images, consecutive characters in NLP, and audio understanding).
As the second candidate of Video Pooling Layer, we use the CNN to capture temporal information of video as proposed in [10]: where conv(input, filter, bias) indicates convolution layer with stride 1, and ReLU indicates the element-wise ReLU activation [12]. w conv ∈ R cv×c h ×1×d is a convolution filter with the vertical and horizontal filter size of c v = 5, c h = 1152, and b conv ∈ R d is a bias. o c ∈ R (T −cv+1)×d indicates the output of the convolution layer. Finally, we apply max-pooling over time for o c , obtaining the d-dimensional encoding of g θ .

Position Encoding
We also test the Position Encoding scheme [14] that assigns different weights to each frame vector. That is, we define the matrix L ∈ R T ×1152 , Position Encoding is simply defined as follows.
After applying Position Encoding, we used summation of each vector as output of g θ , that menas O g is d-dimensional vector where d is 1,152.

Self-Attention: Indirect Clustering
The YouTube-8M dataset deals with general topics (e.g. soccer, game, car, animation) rather than relatively focused labels like Sports-1M or UCF-101. We here test the following hypothesis: since the topic is highly general, it may be more advantageous to focus on the most dominant parts of the video rather than temporal/motion information of individual frames. Therefore, we suggest an indirect clustering model using the self-attention mechanism as follows.
We perform a clustering on the video features over all frames I ∈ R T ×1,152 , and find the cluster with the largest size (i.e. the largest number of elements in the cluster). Then, the vectors in this cluster may represent the main scene of the video. However, since it takes very long time to perform clustering on each video, we propose a selfattention mechanism that acts like clustering as follows.
where p t is a scalar value that indicates the soft attention to a frame t while the softmax is applied over p 1..T . That is, the more similar the frame vector is to the other vectors, the higher its p t value is (i.e. it is more likely to be the main scene of the video). Finally, the frame encoding is simply obtained by a weighted sum of frame vectors by the attention values: g θ = T t=1 p t I t .

Adaptive Noise
Each of 4,716 classes in the YouTube-8M dataset has a different number of video examples. For example, the Car class has about 800,000 examples, but the Air Gear class has only 101 examples. Let n to be the number of labels associated with a video I; we introduce the adaptive noise structure to relieve the label imbalance problem as follows.
where Z ∼ N (0, where noise Z is sampled from normal distribution, y i denotes the i-th label for video, and S(y i ) is the number of video examples that have label y i . It means that we increase the generalization for small classes by adding more noise to their frame vectors. We then make summation of the vectors of all frames as the output of g θ , as done in the position encoding.

Classification Layer
Classification Layer h θ is defined as follows.
That is, by default, h θ takes frame encoding O g as an input and outputs score O h for 4,716 classes. Exceptionally, as shown in figure 1, the Many-to-Many model has I as its input, where I is untouched by video pooling layer g θ . We have conducted experiments on the following three structures in this component. (see figure 3(a))

Many-to-Many
Unlike other models, Many-to-Many model has a frame vector I that is not touched by video pooling layer g θ . It uses LSTM similar to that of 2.2.1, but it calculates the score by attaching fully-connected layer to each output of each step in LSTM and average them, which is used as output O h . Since this model averages out the score in each frame, it has the temporal encoding ability of the RNN as well as the fact that the scores drawn in the more frequently appearing frames are reflected more. As a result, more effective video encoding could be performed.

Variants of Mixture of Experts
The Mixtures of Experts [8] model is a binary classifier that adaptively takes into account the scores of several experts corresponding to a class. For one class, each expert e i has a probability value between 0 and 1, and gate g i represents the weight for each expert and is defined as follows.
where w e , w g are d-dimensional vectors, scalars b e , b g are biases, and softmax is performed for {g 1 , ..., g E }. (E is number of experts.) We extend this MoE model to multilayer, and construct multiple fully-connected of defining probability and gate distribution of each expert. For example, the gate distribution and the expert distribution of the 2-layer MoE model are defined as follows.
where each weight matrix W e , W g is denoted by

Multi Layer Perceptron
The Multi Layer Perceptron model is stack of Fully-Connected Layers, one of the most basic Neural Network structures. We experimentally set the number of layers to 3 and apply Layer Normalization [2] to each layer.

Label Processing Layer
Label Processing Layer C θ is defined as follows.
This component is designed to reflect the correlation between the labels into the model.
where M c is correlation matrix and the correlation value M c [i, j] between the i-th label and the j-th label is calculated higher as i-th label and j-th label appear together more in the same video. Then, a new score is defined as follows to better reflect the correlation between labels through simple linear combination of matrix-vector multiplication.
Here, M c is used as a fixed value, and M c is a trainable parameter initialized to the same value as M c . Scalar values α, β, γ are hyperparameters for model.

Center Loss
Center Loss was first proposed for face recognition task [18] and expanded to other field because of its effectiveness for making dicriminative embedding feature [17]. The purpose of the center loss is to minimize intra-class variations while maximizing inter-class variations using the joint supervision of cross-entropy loss and center loss. The original center loss was used for the single label classification problem and it is hard to exploit it in a multi-label classification problem.
If we convert the multi label problem into a single label problem like [3], increment of centers according to the combination of labels is the simple expansion of center loss to a multi-label classification problem. However, this simple expansion is not suitable for YouTube-8M, because the number of combination for labels is too big to calculate. Therefore, we modified the center loss to suit the multi-label classification problem as follow.
Where N denotes the number of labels in one video. e i denotes a embedding vector from penultimate layer, c k denotes the y i -th corresponding class center for each e i . The L s is the cross-entropy loss, L c is the center loss. A scalar λ is a hyperparameter for balancing the two loss functions.

Pseudo-Huber Loss
The Huber Loss is a combination of L2 Loss and L1 Loss, which allows the model to be trained more robustly on noise instances. In the case of the YouTube-8M, there are classes with very few instances due to the label imbalance problem, and Huber Loss is designed to better learn instances belonging to these classes. For a simple, differentiable form, we use the Pseudo-Huber Loss function, a smooth approximation of the Huber Loss, as follows.
where L CE means that Cross-Entropy Loss between our prediction O c and ground-truth label y, δ means hyperparameter for model.

Training
For training our model, we choose the Adam [11] optimizer using a batch size of 128, with learning rate = 0.0006, β 1 = 0.9, β 2 = 0.999, = 1e − 8. We also apply learning rate decay with the rate = 0.95 for every 1.5M iterations. We train the model for 5 epochs with no early stopping. We use both official training and validation data that YouTube-8M public dataset provides for training our models.

Experiments
We use the test data from the Kaggle competition: Google Cloud & YouTube-8M Video Understanding Challenge to measure the performance of the model. The source for our model is publicly available 2 .

Experimental Setting
One of the greatest features of our model is that we have three issues to solve the YouTube-8M classification task; i)temporal encoding for video, ii)label imbalance problem, iii)correlation between labels, and we have tried several variations on each component by dividing the model pipeline into four components; i)Frame Encoding, ii)Classification Layer, iii)Label Processing Layer, iv)Loss Function. In addition, except in the Many-to-Many model in our pipeline, each component is completely independent of one another, so it is a very good structure for experimenting with a number of variant model combinations. variations that each component can try. Thus, we took the greedy approach, fixed the remaining 3 components in each component, and experimented the several structures only for that component, choosing the best-performing structure for each component. We used Google Average Precision 3 (GAP)@20 as a metric to measure the performance of the model.

Video Pooling Layer
There are five transform structures in Video Pooling Layer The results show that the LSTM method has the best performance for encoding frames. Within LSTM, the higher the utilization of the internal information, the higher the performance, indicating that higher performance can be expected if more information can be extracted from other methods such as skip connection in LSTM. On the other hand, unlike the expectation, the LSTM with Layer Normalization has a lower performance than that which is not. Of course, Layer Normalization had the advantage of stable and fast convergence even when 20-30 times learning rate was applied, but when compared to the final performance alone, performance was not good.
CNN showed a very poor performance unexpectedly. As CNN's output channel increased, performance was on the rise, but channels larger than 256 were not experimented because of the memory limitations of the GPU. While we can expect that CNN will perform well for larger channels, another problem with CNN is the dramatic increase in computation cost as channels increase. However, if CNNs with different hyperparameters record similar performance to LSTM, CNN is likely to be used as good pooling method because it has the advantage that the convolution operation is fully parallelizable. The Position Encoding model showed lower performance than LSTM, and one of the possible reasons is that the sequence modeling power of the model is weaker than LSTM.
The Indirect Clustering model has lower performance than LSTM, but it performs better than the Position Encoding model. This suggests that the assumptions we have made (the importance of the main scene in video classification) are not entirely wrong, suggesting that we need a model that can cover this issue more delicately. Also, temporal encoding of LSTM is as important as considering main scene in video classification.
Adaptive Noise do not lead to a significant performance improvement, indicating that a more sophisticated approach to the label imbalance problem is required.

Classification Layer
The Classification Layer h θ has three variants: i)Manyto-Many, ii)Multi-Layer MoE, iii)MLP. To select the best method for h θ , we fix the remaining component g θ with Indirect Clustering, C θ is not used, and L c uses cross entropy loss. (However, in the many-to-many model, g θ is not used according to the definition.) Based on these settings, the results for each of the three structures are shown in Table 3.
2 Layer MoE-2 refers to a 2 layer MoE model with 2 experts, and 2 Layer MoE-16 refers to a 2 layer MoE model with 16 experts. 3 layer MLP-4096 is MLP structure with 4096 dimension of each hidden layer and 3 hidden layers, and 3 layer MLP-4096-LN applies layer normalization to each layer.
In constructing the classification layer, the MLP structure showed the best performance among the three meth-  ods. The Many-to-Many model is an LSTM-based model, but has a lower performance than the basic LSTM structure in Table 2, indicating that the Many-to-Many framework in video classification is not always a good choice.
On the other hand, disappointingly, the Multi Layer MoE model showed severe overfitting in only two layers. As expected, this requires a lot of parameters to create an intermediate level of embedding, which is also needed for each experts, resulting in overfitting for many parameters. We experimented with different number of layers and hidden layer dimensions for the MLP structure, but 4096 dimensions of 3 layers showed the highest performance. Unusual is that, when layer normalization was applied, the MLP model showed improved performance unlike LSTM, and did not require more delicate hyperparameter tuning.

Label Processing Layer
To select the best method for C θ , we fix the remaining component g θ with Indirect Clustering, h θ using the MoE-16 model and L c using the cross entropy loss. As defined in Equation 20, the Label Processing Layer C θ uses precomputed correlation matrix M c . α, β, and γ values can be used to control the degree to which the correlation matrix affects the class score. An experiment is shown in Table 4.
As a result, performance dropped for all β and γ values greater than zero. In other words, when using the label correlation matrix for the purpose of score update, it showed rather low classification performance.
The possible reason for the result may be that our model is too naive to reflect the correlation label prior and that label correlation in the YouTube-8M Dataset is not strong enough to improve the performance of the classification task.

Loss Function
To select the most suitable loss for L c , we fix the remaining component g θ with Indirect Clustering, h θ uses the MoE-16 model, and C θ is not used. Table 5 shows the performance depending on whether or not the center loss and the pseudo-huber loss are used.
L CE is the cross entropy loss, L c is the center loss, and Huber CE is the Pseudo-Huber loss for cross entropy term.
The results show that, firstly, using the center loss term L c gives little performance gain. Considering that we apply the center loss term to the multi-label, the performance should be improved if the labels are correlated with each other. Here we get another insight for the correlation label prior, which is that the correlation does not exist as strongly as to achieve performance improvement. Second, Huber Loss proved its ability to cover noise data somewhat from the YouTube video annotation system 4 by recording a relatively clear performance improvement.

Ensemble Model
Based on the experiments we conducted in section 3.2, we recorded test performance of 0.820 as a single model combining LSTM-M-O, MoE-2, and HuberLoss.(Due to GPU memory limitation, we could not apply MoE-16 or Multi Layer MLP model to LSTM based model) In addition, our ensemble model, which is a simple average of the scores of several models, showed a test performance of 0.839 and ranked 8th in the kaggle challenge. The interesting thing is that when we assemble several models, we did not get a significant performance increase if we combine the better single models. Rather, for increasing ensemble model's performance, the models incorporated should be as diverse as possible.

Conclusion
We defined three issues that need to be covered in order to solve the YouTube-8M Video Classification task, and we divided the model pipeline into four components and experimented with the various structures to solve issues in each component. As a result, almost all of the deformed structures tried to perform better than the baseline, and their ensemble model recorded 0.839 in the test performance and 8th in the kaggle challenge. We also provided insights on the structures we tried on each component, on what roles each structure plays, and why they work well or poor. Based on this insight, we will explore ways of better frame encoding or use more elegant label correlation priorities as our