{'fraction_non_alphanumeric': 0.0368905977945444, 'fraction_numerical': 0.01019297736506094, 'mean_word_length': 4.641293226928586, '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': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Probabilistic Attribute Tree in Convolutional Neural Networks for Facial Expression Recognition

In this paper, we proposed a novel Probabilistic Attribute Tree-CNN (PAT-CNN) to explicitly deal with the large intra-class variations caused by identity-related attributes, e.g., age, race, and gender. Specifically, a novel PAT module with an associated PAT loss was proposed to learn features in a hierarchical tree structure organized according to attributes, where the final features are less affected by the attributes. Then, expression-related features are extracted from leaf nodes. Samples are probabilistically assigned to tree nodes at different levels such that expression-related features can be learned from all samples weighted by probabilities. We further proposed a semi-supervised strategy to learn the PAT-CNN from limited attribute-annotated samples to make the best use of available data. Experimental results on five facial expression datasets have demonstrated that the proposed PAT-CNN outperforms the baseline models by explicitly modeling attributes. More impressively, the PAT-CNN using a single model achieves the best performance for faces in the wild on the SFEW dataset, compared with the state-of-the-art methods using an ensemble of hundreds of CNNs.


INTRODUCTION
As one of the most natural, powerful, and universal means of human communication, facial expression has been studied intensively in various active research fields. Most recently, deep CNNs have attracted increased attention for facial expression recognition. Despite the CNN structures employed, most of these approaches were trained to learn expression-related facial features from all subjects as illustrated in Fig. 1 (a), while identity-related attributes, e.g., age, race, and gender, are not explicitly considered.
However, it is widely believed that facial appearance and 3D geometry are determined by person-specific attributes and affected by facial expressions temporarily. For instance, it is hard to differentiate the transient wrinkles caused by facial expressions from the permanent ones of elder adults. In addition, the presence of facial hair such as beards may introduce various occlusions for male versus female subjects.
Furthermore, studies in psychology have shown that emotional expressions demonstrate considerable differences across age [10], race [41], and gender [41,11,39] in terms of expression intensity. For examples, Asian people show consistently lower intensityexpressions than the other ethnic groups [27]; and women were found to express more anger [11] and sadness [39] than men do. Due to high inter-subject variations caused by attributes, it remains challenging to learn expression-related features with CNNs, especially from static images. This motivates us to alleviate identity-related variations by explicitly modeling person-specific attributes in CNNs.
An intuitive solution is to train multiple attribute-specific CNNs from subsets of the dataset. As shown in Fig. 1 (b), a set of CNNs can be trained from different combinations of attributes, respectively. However, unlike large-scale datasets for object detection or categorization, expression-labeled datasets are much smaller and most of them lack attribute annotations. Moreover, classifying attributes in the real world is still a challenging problem. Therefore, recognition performance of attribute-specific CNNs is likely to degrade due to misclassified attributes and insufficient training data in the subsets as demonstrated in our experiments.
In this work, we proposed a novel PAT-CNN, where features are learned through a hierarchical tree structure organized according to attributes. As shown in Fig. 1 (c), a novel PAT module is embedded right after the last pooling layer. The PAT module has a hierarchical tree structure, where each node contains a fullyconnected (FC) layer connected to the FC layer in its parent node, if any.
Given a set of training samples, clustering is conducted at each node except the leaf nodes according to a type of attributes by using features from the current FC layer in that node. Hence, the number of child nodes is determined by the number of clusters, i.e., the number of states of the attribute. For example, as shown in Fig. 1 (c), clustering is performed in terms of "Gender" at the root node and results in two clusters corresponding to two child nodes for male and female, respectively. Since the goal is NOT attribute recognition, each data sample is probabilistically assigned to all nodes. As depicted in Fig. 1 (c), a female Caucasian has a high probability to be assigned to "Female" node at the second level and "Female Caucasian" node at the third level. Expressionrelated features, i.e., the output of the PAT module, are extracted from the FC layers at the leaf nodes, from which a set of expression  trained from subsets of the dataset, and (c) the proposed PAT-CNN, where each node contains an FC layer connected to FC layer in its parent node, if any. Dots represent cluster centers, each of which corresponds to a state of the specific attribute. The green dots denote the cluster centers corresponding to the ground truth attribute states of the current sample, e.g., "Female" for gender in the root node. Best viewed in color.
classifiers are trained. The final decision of expression classification is achieved by a weighted sum of all expression classifiers.
Furthermore, a semi-supervised learning strategy is developed to learn the PAT-CNN from limited attribute-annotated data. In addition to the loss for expression classification, a novel PAT loss function is developed to iteratively update cluster centers, shown as blue and green dots in Fig. 1 (c), during training, which ensures clustering results are semantically meaningful. Specifically, the data samples with attribute labels are used to minimize the PAT loss; whereas all samples with expression labels are employed to minimize the expression loss. Note that the attribute labels are only used in training, but not in testing.
In summary, our major contributions are: -Developing a PAT-CNN to alleviate variations introduced by person-specific attributes for facial expression recognition. -Developing a novel PAT module with an associated PAT loss to learn expression-related features in a hierarchical manner, where the output features of the PAT module are less affected by attributes. -Developing a semi-supervised learning strategy to train the PAT-CNN from limited attribute-annotated data, making the best use of available facial expression datasets. Extensive experiments on five expression datasets show that the proposed PAT-CNN yields considerable improvement over the baseline CNNs learned from all training data (Fig. 1 a) as well as the attribute-specific CNNs learned from subsets of the dataset (Fig. 1 b). We also showed that the proposed soft-clustering with probability outperforms the one based on hard-clustering using the same network structure. More impressively, the PAT-CNN using a single model achieves the best performance for faces in the wild on the SFEW dataset, compared with state-of-the-art methods using an ensemble of hundreds of CNNs.

RELATED WORK
Facial expression recognition has been extensively studied as elaborated in the recent surveys [36,26]. One of the major steps in facial expression recognition is to extract features that capture the appearance and geometry changes caused by facial behavior, from either static images or dynamic sequences. These features can be roughly divided into two main categories: hand-crafted and learned features. Recently, features learned by deep CNNs have achieved promising results, especially in more challenging settings. Most of these approaches were trained from all training data, whereas attribute-related and expression-related facial appearances are intertwined in the learned features. While progress has been achieved in choices of features and classifiers, the challenge posed by subject variations remains for person-independent recognition.
More recently, identity information is explicitly taken into consideration when learning the deep models. An identity-aware CNN [28] developed an identity-sensitive contrastive loss to learn identity-related features. An Identity-Adaptive Generation (IAgen) method [46] was proposed to synthesize person-dependent facial expressions from any input facial images using six conditional Generative Adversarial Networks (cGANs); and then recognition is performed by comparing the query images and the six generated expression images, which share the same identity information. The cGAN was also used in De-expression Residue Learning (DeRL) [45] to generate a neutral face image from any input image of the same identity, while the residue of the generative model contains person-independent expression information.
Apart from learning identity-free expression-related features, Multi-task Learning (MTL) has been employed [33] to simultaneously perform various face-related tasks including detection, alignment, pose estimation, gender recognition, age estimation, smile detection, and face recognition using a single deep CNN. To deal with the incomplete annotations and thus, insufficient and unbalanced training data for various tasks, the all-in-one framework was split into subnetworks, which were trained individually. Our approach differs significantly from the MTL [33] that we jointly minimize the loss of the major task, i.e., expression recognition errors, and those of the auxiliary tasks, i.e., the PAT loss, calculated in a hierarchical tree structure. In addition, semi-supervised learning is employed in our approach to make the best use of all available data.
Recently, clustering has been utilized to group deep features. A recurrent framework [47] updates deep features and image clusters alternatively until the number of clusters reaches the predefined value. DeepCluster [4] alternatively groups the features by k-means and uses the subsequent assignments as supervision to learn the network. Deep Density Clustering (DDC) [21] groups unconstrained face images based on local compact representations and a density-based similarity measure. In contrast to these unsupervised clustering methods, the proposed PAT-CNN takes advantage of available attribute annotations and thus, is capable of learning semantically-meaningful clusters that are related to facial expression recognition. Moreover, data samples are probabilistically assigned to clusters at different levels of the hierarchy to alleviate the misclassifications due to clustering errors.

METHODOLOGY
In this section, we will first introduce the proposed PAT module, then present the PAT loss and the corresponding forward and backward propagation processes. Finally, we will show the overall loss function of the PAT-CNN.

The Overview of the PAT Module
The architecture of the proposed PAT-CNN is illustrated in Fig. 2, where a general l-Level PAT module is embedded between the last pooling layer and the decision layer of the CNN. Level-1 of the PAT contains the root node, which has one FC layer connected to the last pooling layer. Starting from Level-2, each level consists of a number of nodes, each of which contains an FC layer connected to the FC layer located at its parent node at the previous level.
Excepting the leaf nodes, clustering is performed at each PAT node according to a type of attribute, e.g., age, race, and gender; and nodes in the same level consider the same type of attribute. As shown in Fig. 2, features extracted from the associated FC layer are clustered into a number of clusters with the centers denoted as blue or green dots. The number of clusters is determined by the number of states of the specific attribute, e.g., 2 for gender. Furthermore, these clusters also correspond to its child nodes in the next level. As shown in Fig. 1 (c), a "Female" cluster in the root node corresponds to one of its child nodes, i.e., the "Female" node.
During training, the samples with the attribute labels will be used to update the cluster centers and learn the parameters of the FC layers of the PAT module by minimizing the proposed PAT Figure 2: An illustration of the PAT-CNN. Each node contains an FC layer, which connects to another FC layer located at its parent node, if any. At each node except the leaf nodes, features are extracted at the associated FC layer and clustered according to a specified attributes, e.g., age , gender, and race, with centers marked by dots. The green dots denote the cluster centers corresponding to the ground truth attribute states of the current sample. Intensity of red nodes represents the probability of the current sample belonging to the node. Best viewed in color.
loss. As shown in Fig. 2, each sample contributes to all nodes differently according to its probabilities of belonging to the nodes illustrated by the color intensities of the nodes. Specifically, a sample contributes more to those nodes containing the green dots, which denote the cluster centers corresponding to its ground truth attribute states, but also to other nodes with lower probabilities. As shown in Fig. 1 (c), a sample of a female Caucasian will contribute more to learn the parameters associated with the "Female" node at the second level and "Female Caucasian" node at the third level, but less to the other nodes.

The PAT Loss: Forward Propagation
The PAT loss denoted as L PAT measures how far away the data samples are from their corresponding cluster centers and is calculated from samples with attribute labels. It is defined as the summation of the attribute losses of all levels except the leaf one: where l is the number of PAT levels. LA j is the attribute loss of the j th level, which is defined as: where Kj is the number of tree nodes at the j th level; and LA jk is the attribute loss of the k th node at the j th level. From now on, the subscript j and k denote the variable at the j th level and the k th node, respectively. Let C jk denote a set of cluster centers and x ijk denote the feature vector of the i th sample extracted from the FC layer in the k th node at the j th level. Given Na j data samples with the attribute labels, LA jk is calculated as: where y a ij denotes the ground truth attribute label of the i th sample at the j th level, e.g., gender ="Female" in Fig. 1 (c). c jkm ∈ C jk denotes the m th cluster center in the k th node, i.e., a dot in the k th node; and c y a ij ∈ R d denotes the cluster center corresponding to the ground truth attribute label, i.e., the only green dot at the j th level, in Fig. 1 (c) and Fig. 2. D(a, b) is a distance function and defined as a cosine distance between two vectors in this work.
c jkm has three conditions: (1) c jkm = c y a ij (the m th cluster is denoted by a green dot), (2) c y a ij ∈ C jk and c jkm = c y a ij (the k th node contains the green dot, but the m th cluster is denoted by a blue dot); and (3) c y a ij / ∈ C jk (the k th node contains all blue dots). Thus, each attribute loss LA jk is calculated by Eq. 3 in two cases. Using Fig. 1 (c) as an example, both "Female" and "Male" nodes contain three clusters according to "Race". In the first case, LA jk of the "Female" node is calculated such that the current sample, i.e., a female Caucasian, will be pushed to the center "Caucasian" by minimizing the loss term 1 − D(x ijk , c y a ij ) and pulled away from the other centers by minimizing the loss term (1 + D(x ijk , c jkm )). In the second case, LA jk of the "Male" node is calculated such that the sample will be pulled away from all the centers by minimizing the loss (1 + D(x ijk , c jkm )).
p (c jkm |x ijk ) is the probability of x ijk belonging to the m th cluster and also the probability of the i th sample being assigned to the m th child node at the j + 1 th level. p (c jkm |x ijk ) is defined as: where q ijk is the probability of the i th sample belonging to the k th node at the j th level and is calculated at its parent node as described above.

The PAT Loss: Backward Propagation
The partial derivative of the PAT loss L PAT with respect to the input sample can be calculated at each node as: where |C jk | is the number of cluster centers in the k th node and is defined as: (6) Then, the m th cluster center can be updated iteratively in each mini-batch with a learning rate α:

A Marginal Softmax Loss
As shown in Fig. 2, the outputs of the PAT module, i.e., features extracted from the FC layers at the leaf nodes in the l th level, are used to train a set of expression classifiers, respectively. The final expression decision is achieved by a weighted sum of all expression classifiers. Given Ne data samples with expression labels, the marginal softmax loss function is defined as follows: where x ilk is the feature vector of the i th sample extracted from the k th node, i.e., the leaf level, of PAT; K l is the number of leaf nodes at the l th level and is also the number of expression classifiers. p(y e i |x ilk ) is the prediction score of the i th sample displaying the expression of y e i . q ilk is the probability of the i th sample belonging to the k th node at the l th level and propagated from its parent node, as described previously. Therefore, given Na data samples with attribute labels and Ne data samples with expression labels, the overall loss function of the PAT-CNN training is given below: where λ is a hyperparameter 1 to balance the two losses. Note that Na and Ne are not necessarily the same and L PAT can be calculated from a small subset of attribute-labeled data. This enables a semi-supervised learning of the PAT-CNN and makes it feasible to improve expression recognition for those existing datasets without attribute labels with the help of additional attribute-labeled data.
The forward and backward training process in the PAT-CNN is summarized in Algorithm 1.  Update the network layer parameters: 13: 14: end for Output: Network layer parameters W, marginal softmax loss parameters θ, and PAT loss parameters, i.e., the cluster centers at the level 1 to l − 1.

Preprocessing
Face alignment was employed on each image based on centers of two eyes and nose, extracted by Discriminative Response Map Fitting (DRMF) [1]. The aligned facial images were then resized to 256 × 256. In addition, histogram equalization was utilized to improve the contrast in facial images. For data augmentation purpose, 224 × 224 patches were randomly cropped from the 256 × 256 images, and then rotated by a random degree between -5 • and 5 • . Finally, the rotated images were randomly horizontally flipped as the input of all CNNs in comparison.

Experimental Datasets
RAF-DB dataset provides attribute labels, e.g., age, race, and gender, for each image and thus, was employed as the major dataset for experimental validation in this work. Specifically, the single-label subset of the RAF-DB (12,271 training images and 3,068 testing images) was employed, where each image was labeled as one of seven expressions, i.e., neutral and six basic expressions. The subjects were divided into five age groups: (1) 0-3, (2) 4-19, (3) 20-39, (4) 40-69, (5) 70+ with the gender attribute labeled as one of the three categories, i.e., male, female, and unknown 2 , and the race attribute labeled as one of the three categories, i.e., African-American, Asian, and Caucasian. SFEW dataset is the most widely used benchmark dataset for facial expression recognition in the wild. It contains 1,766 facial images and has been divided into three sets, i.e. Train (958), Val (436), and Test (372). Each image has one of seven expression labels, i.e., neutral and six basic expressions. The expression labels of the "Test" set are not publicly available. Thus, the performance on the "Test" set was evaluated and provided by the challenge organizer. BU-3DFE dataset consists of 2,500 pairs of static 3D face models and 2D texture images from 100 subjects with a variety of ages and races. Each subject displays six basic expressions with four levels of intensity and a neutral expression. Following [45,46], we employed only the 2D texture images of the six basic expressions with high intensity (i.e., the last two levels) in our experiment. Thus, an experimental dataset including 1,200 images was built for the BU-3DFE dataset. CK+ dataset consists of 327 videos collected from 118 subjects, each of which was labeled with one of seven expressions, i.e., contempt and six basic expressions. Each video starts with a neutral face, and reaches the peak in the last frame. To collect more data, the last three frames were collected as peak frames associated with the provided label. Hence, an experimental dataset including 981 images was built for seven expressions and 927 images for six basic expressions. MMI dataset contains 236 sequences from 32 subjects, from which 208 sequences of 31 subjects display six basic expressions captured in frontal-view were normally used in experimental validation. Sequences in MMI start from a neutral expression, through a peak phase near the middle, and back to a neutral face at the end. Since the actual location of the peak frame was not provided, three frames in the middle of each sequence were collected with the labeled expression Thus, a total of 624 images were used in our experiments.

Training/testing strategy
Because the three posed facial expression datasets do not provide specified training, validation, and test sets, a person-independent 10-fold cross-validation strategy was employed, where each dataset was further split into 10 subsets, and the subjects in any two subsets are mutually exclusive. For each run, data from 8 sets were used for training, the remaining two subsets were used for validation and testing, respectively. The results were reported as the average of the 10 runs on the testing sets. For the experiments on the SFEW and RAF-DB datasets, we used their training sets for training and their validation and/or testing sets for evaluation, respectively.  In this work, a pre-trained VGG-Face CNN model [32] and a ResNet-34 pre-trained on the ImageNet dataset [34] were employed as our backbone CNN networks. Training baseline models: For experiments on the BU-3DFE, CK+, MMI, and SFEW datasets, two baseline CNNs, i.e., VGG-Face model and ResNet-34, were finetuned by using its own training set and the RAF-DB training set. We employed 50% images from the RAF-DB in every mini-batch. For experiments on the RAF-DB dataset, they were fine-tuned by only using the RAF-DB training set. Training the PAT-CNN models: The proposed PAT-CNN models used the same training strategy as the two baseline models, i.e., always including RAF-DB in training, for evaluation on each dataset. Note, only images from the RAF-DB dataset were used to calculate the PAT loss and all training samples were employed to calculate the expression loss as in Eq. 12. In this work, age, race, and gender were chosen to construct the PAT module. As shown in Fig. 3, we constructed several variants of PAT modules by varying the number of levels and/or the orders of attributes using the VGG-Face backbone. Then, an l-Level PAT module is denoted by a tuple (attribute 1, attribute 2, ...). Thereafter, variants of the proposed PAT-CNNs are denoted as PAT-VGG-(attribute 1, attribute 2, ...) or PAT-ResNet-(attribute 1, attribute 2, ...).
In addition, we reported the results of three attributespecific CNNs, i.e., VGG(age), VGG(race), and VGG(gender), which were trained from subsets of dataset as illustrated in Fig. 1 (b). As expected, the performances of the attribute-specific VGGs are consistently worse than the baseline VGG due to insufficient training data in subsets. Furthermore, we have demonstrated that Table 1: Performance comparison on the RAF-DB. Some papers report performance as an average of diagonal values of confusion matrix. We convert them to regular accuracy for fair comparison.

Method
Accuracy Kuo et al. [17] 72.21 FSN [53] 81.10 MRE-CNN [9] 82.63 baseDCNN [19] 82.66 DLP-CNN [19] 82.84 Center Loss [19] 82.86 PG-CNN [20] 83 the soft-clustering with probability outperforms hardclustering, i.e., AT-VGG-(gender, race), using the same network structure. Moreover, we evaluated the semi-supervised learning strategy for PAT-CNN training, which is critical for realworld applications, where attribute information may be missing or incomplete. Specifically, we varied the percentage of attribute-labeled images from 100% to 10% by randomly removing attribute labels for RAF-DB images. As shown in Fig. 4, the performance of PAT-VGG-(gender, race) beats that of the VGG baseline when more than 20% of RAF-DB images have attribute labels.

Result analysis for the three posed datasets
As shown in Table 2, 3, and 4, the proposed PAT-CNNs outperforms the baseline CNNs for both backbone structures and also achieve comparable results as the stateof-the-art methods evaluated on the three posed datasets. Note that most of the state-of-the-art methods utilized dynamic features extracted from image sequences, while the proposed PAT-CNN is trained on static images, which is more favorable for online applications or snapshots. Yang et

Result analysis for the SFEW dataset
More importantly, the proposed PAT-CNN was also evaluated on the SFEW dataset, which contains unconstrained and thus, more natural facial expressions and has been used as a benchmark to evaluate facial expression recognition systems in the wild. Note that the top three methods reported on the SFEW testing set [16,51,3] utilized an ensemble of CNNs. As shown in Table 5, the proposed PAT-CNNs beat the baseline CNNs for both validation set and testing set by a large margin. More impressively, the proposed PAT-CNNs with both backbone structures using a single model achieve the best performance on the testing set among all the methods compared with.

CONCLUSION
In this work, we proposed a novel PAT-CNN along with a forward-backward propagation algorithm to learn expression-related features in a hierarchical structure by explicitly modeling identity-related attributes in the CNN. Our work differs from the other unsupervised clustering methods in that the proposed PAT-CNN is capable of building semantically-meaningful clusters from which expression-related features are learned to alleviate the inter- subject variations. Furthermore, data samples have different weights, i.e., the probabilities of being assigned to the nodes, in training the PAT nodes; and the probabilities are also used as the weights to build a strong classifier for expression recognition. More importantly, most of the existing facial expression datasets do not have attribute labels. The proposed loss function enables a semisupervised learning strategy to improve expression recognition for these databases with the help of additional attributelabeled data, such as the RAF-DB. Facial expression recognition has achieved great progress on posed facial displays in lab settings ( Table 2, 3, and 4), but suffers in real world conditions (Table 1 and 5), which significantly impedes its applications. The PAT-CNNs achieved the best performance on both spontaneous databases (RAF-DB and SFEW datasets) in the realworld setting by explicitly handling large attribute variations. In the future, we plan to apply the PAT-CNN to other classification problems that suffer from large intraclass variations.

Acknowledgement
This work is supported by National Science Foundation under CAREER Award IIS-1149787.