Dynamic Curriculum Learning for Imbalanced Data Classification

Yiru Wang, Weihao Gan, Jie Yang, Wei Wu, Junjie Yan

Introduction

Human attribute analysis, including facial characteristics and clothing categories, has facilitated the society in various aspects, such as tracking and identification. However, different from the general image classification problem like ImageNet challenge , human attribute analysis naturally involves largely imbalanced data distribution. For example, when collecting the face data of attribute ‘Bald’, most of them would be labeled as ‘No Bald’ and its imbalanced ratio to the ‘Bald’ class would be relatively high. Training the classification model with equal importance for samples in different classes may result in a bias to the majority class of the data and poor accuracy for the minority class. Therefore, it is of great importance to handle the imbalanced data learning problem, especially in human attribute analysis.

Impressive results have been achieved for the general imbalanced data learning in the past years. One intuitive motivation is resampling , which either oversamples the minority class data or downsamples the majority class data, to balance the data distribution. However, oversampling could easily cause overfitting problem due to repeatedly visiting duplicated minority samples, while downsampling may discards much useful information in the majority samples. Another kind of approach called cost-sensitive learning is also exploited to handle the imbalanced data learning problem, which directly imposes heavier cost on the misclassified minority class . However, it is difficult to determine the exact cost for different samples in various distributions. Hand et al. proposed a batch-wise method that selects part of the majority samples and increases the weight of minority samples to match a pre-defined target distribution. Besides the standard cross entropy classification loss, Dong et al. proposed to add another class rectification loss (CRL) to avoid the dominant effect of majority classes. A specific metric is proposed for imbalanced datasets by above methods. For the general classification problem, class-biased accuracy is defined as the number of correctly predicted samples divided by the number of the whole test data. While for imbalanced data classification, class-balanced accuracy is defined as the average of the accuracy in each class for evaluation.

Our proposed Dynamic Curriculum Learning (DCL) method is motivated by the following two considerations. (1) Sampling is an acceptable strategy for the problem, but keeping targeting at a balanced distribution in the whole process would hurt the generalization ability, particularly for a largely imbalanced task. For example, in the early stage of learning with balanced target distribution, the system discards lots of majority samples and emphasizes too much on the minority samples, tending to learn the valid representation of the minority class but the bad/unstable representation of the majority one. However, what we expect is to make the system first learn the appropriate general representations for both of the classes on the target attributes and then classify the samples into correct labels, which results in a favorable balance between the class bias accuracy and class balanced accuracy. (2) It is reasonable to combine cross entropy loss (CE) and metric learning loss (ML) since the appropriate feature representation could be helpful for classification. However, we think those two components contribute to different emphasis. Treating them equally in the training process cannot fully utilize the discriminative power of deep CNN. Specifically, CE pays more attention to the classification task by assigning specific labels, while ML focuses more on learning a soft feature embedding to separate different samples in feature space without assigning labels. Similarly to the previous point, we expect the system first to learn the appropriate feature representation and then classify the samples into the correct labels.

In the spirit of the curriculum learning , we propose Dynamic Curriculum Learning (DCL) framework for imbalanced data learning. Specifically, we design two-level curriculum schedulers: (1) sampling scheduler: it aims to find the most meaningful samples in one batch to train the model dynamically from imbalanced to balanced and from easy to hard; (2) loss scheduler: it controls the learning weights between classification loss and metric learning loss. These two components can be defined by the scheduler function, which reflects the model learning status. To summarize our contributions:

For the first time, we introduce the curriculum learning idea into imbalanced data learning problem. Based on the designed scheduler function, two curriculum schedulers are proposed for dynamic sampling operation and loss backward propagation.

The proposed DCL framework is a unified representation, which can generalize to several existing state-of-the-art methods with corresponding setups.

We achieve the new state-of-the-art performance on the commonly used face attribute dataset CelebA and pedestrian attribute dataset RAP .

Related Work

Imbalanced data learning. There are several groups of methods trying to address the imbalanced learning problem in literature. (1) Data-level: considering the imbalanced distribution of the data, one intuitive way to do is resampling the data into a balanced distribution, which could oversample the minority class data and downsample the majority class data. One advanced sampling method called SMOTE augments artificial examples created by interpolating neighboring data points. Some extensions of this technique were proposed . However, oversampling can easily cause overfitting problem due to repeatedly visiting duplicated minority samples. While downsampling usually discards many useful information in majority samples. (2) Algorithm-level: cost-sensitive learning aims to avoid above issues by directly imposing a heavier cost on misclassifying the minority class . However, how to determine the cost representation in different problem settings or environments is still an open question. Besides of the cost-sensitive learning, another option is to change the decision threshold during testing, which is called threshold-adjustment technique . (3) Hybrid: this is an approach that combines multiple techniques from one or both abovementioned categories. Widely used example is ensembling idea. EasyEnsemble and BalanceCascade are methods that train a committee of classifiers on undersampled subsets . SMOTEBoost, on the other hand, is a combination of boosting and SMOTE oversampling . Some methods like also pays attention to the noisy samples in the imbalanced dataset.

Deep imbalanced learning. Recently, several deep methods have been proposed for imbalanced data learning . One major direction is to integrate the sampling idea and cost-learning into an efficient end-to-end deep learning framework. Jeatrakul et al. treated the Complementary Neural Network as an under-sampling technique, and combined it with SMOTE-based over-sampling to rebalance the data. Zhou et al. studied data resampling for training cost-sensitive neural networks. In , the cost-sensitive deep features and the cost parameter are jointly optimized. Oquab et al. resampled the number of foreground and background image patches for learning a convolutional neural network (CNN) for object classification. Hand et al. proposed a selective learning(SL) method to manage the sample distribution in one batch to a target distribution and assign larger weight for minority classes for backward propagation. Another recent direction of the problem involves the metric learning into the system. Dong et al. proposed a class rectification loss (CRL) regularising algorithm to avoid the dominant effect of majority classes by discovering sparsely sampled boundaries of minority classes. More recently, LMLE/CLMLE are proposed to preserve the local class structures by enforcing large margins between intra-class and inter-class clusters.

Curriculum learning. The idea of curriculum learning was originally proposed in , it demonstrates that the strategy of learning from easy to hard significantly improves the generalization of the deep model. Up to now, works been done via curriculum learning mainly focus on visual category discovery , object tracking , semi-/weakly-supervised learning , etc. proposed an approach that processes multiple tasks in a sequence with sharing between subsequent tasks instead of solving all tasks jointly by finding the best order of tasks to be learned. Very few works approach the imbalanced learning. Guo et al. developed a principled learning strategy by leveraging curriculum learning in a weakly supervised framework, with the goal of effectively learning from imbalanced data.

Method

We propose a Dynamic Curriculum Learning (DCL) framework for imbalanced data classification problem, consisting of two-level curriculum schedulers. The first one is a sampling scheduler of which the key idea is to find the most significant samples in one batch to train the model dynamically making data distribution from imbalanced to balanced and from easy to hard. This scheduler determines the sampling strategy for the proposed Dynamic Selective Learning (DSL) loss function. The second one is the loss scheduler, which controls the learning importance between two losses: the DSL loss and the metric learning loss (triplet loss). Therefore, in the early stage of the training process, the system focuses more on the soft feature space embedding, while later on, it pays more attention to the task of classification.

Most of the traditional curriculum learning methods manually define different training strategies. While in our proposed DCL framework for imbalanced data learning, we formulate the key idea of curriculum scheduling with different groups of functions, as we called Scheduler Function. We show the semantic interpretation for those functions.

The scheduler function SF(l)SF(l) is a function which returns value monotonically decreasing from 1 to 0 with the input variable ll, which represents the current training epoch. It reflects the model learning status and measures the curriculum learning speed. We explore several function classes as following (illustrated in Figure 1):

Convex function: indicating the learning speed from slow to fast. For example:

Linear function: indicating the constant learning speed. For example:

Concave function: indicating the learning speed from fast to slow. For example:

Composite function: indicating the learning speed from slow to fast and then slow again. For example:

where LL refers to expected total training epochs and λ\lambda is an independent hyperparameter that in the range of (0,1)(0,1).

Different classes of SF(l)SF(l) represent different curriculum learning styles. Based on the above-introduced scheduler functions, we propose Dynamic Curriculum Learning framework for imbalanced data classification.

2 Sampling Scheduler

Sampling is one of the most commonly used techniques to deal with imbalanced data learning. In this section, we introduce the proposed Dynamic Selective Learning (DSL) component, which is based on our sampling scheduler. The sampling scheduler dynamically adapts the target distribution in a batch from imbalanced to balanced during the training process.

Explicitly, for each attribute, we define jthj^{th} element of the data distribution DD as the number of jthj^{th} class samples divided by the number of minority samples (the least one). Sorting them in ascending order, then we have:

where KK is the number of classes and #Ci\#C_{i} is the number of samples in class ii. Each attribute has its training distribution DtrainD_{train}, which is a global statistic.

Sampling scheduler determines the target data distribution of the attributes in each batch. Initially, the target distribution of one attribute Dtarget(0)D_{target}(0) in a batch is set to DtrainD_{train}, which is imbalanced distributed. During the training process, it gradually transfers to a balanced distribution with the following function (each element is powered by g(l)g(l)):

where ll refers to current training epoch and g(l)g(l) is the sampling scheduler function, which can be any choice in Section 3.1. According to target distribution Dtarget(l)D_{target}(l) , the majority class samples are dynamically selected and the minority class samples are re-weighted in different epochs to confirm different target distributions in one batch. Therefore, the DSL loss is defined as:

where NN is batch size, NjN_{j} is the number of samples of jthj^{th} class in current batch, MM is number of classes, yˉi,j\bar{y}_{i,j} is the ground truth label. wjw_{j} is the cost weight for class jj. Dtarget,j(l)D_{target,j}(l) is the jthj^{th} class target distribution in current epoch ll. Dcurrent,jD_{current,j} is the jthj^{th} class distribution in current batch before sampling. If Dtarget,j(l)Dcurrent,j<1\frac{D_{target,j}(l)}{D_{current,j}}<1, we sample Dtarget,j(l)Dcurrent,j\frac{D_{target,j}(l)}{D_{current,j}} percentage of jthj^{th} class data with original weight 1 and the remainings with 0. If not, then jthj^{th} class is a minority class and a larger weight is assigned to the samples.

With different sampling scheduler functions (four types in the previous section), the batch target distribution changes from the training set biased distribution to balanced distribution. At the beginning epoch, g(0)=1g(0)=1, the target distribution DD equals to the train set distribution; in other words, the real-world distribution. At the final epoch, g(l)g(l) is close to 0, so all the element in target distribution DD is close to 1 (power of 0). In other words, it is a balanced distribution.

The learning rate is usually set conforming to a decay function. At the early stage of the training process, with a large learning rate and biased distribution, the curriculum scheduler manages the model to learn more on whole training data. Usually, the system learns lots of easy samples in this stage. Going further with the training process, the target distribution is gradually getting balanced. With the selected majority samples and re-weighted minority samples, the system focuses more on the harder situation.

3 Metric Learning with Easy Anchors

Besides of the loss functionLDSL\mathcal{L}_{\text{DSL}}, we also involve a metric learning loss to learn a better feature embedding for imbalance data classification.

A typical selection of the metric learning loss is triplet loss, which was introduced by CRL with hard mining. Define the samples with high prediction score on the wrong class as hard samples. Then we build triplet pairs from the anchors and some hard positive and negative samples. The loss function in CRL is defined as following:

where mjm_{j} refers to the margin of class jj in triplet loss and d(⋅)d(\cdot) denotes the feature distance between two samples. In current batch, xall,j\textbf{x}_{all,j} represents all the samples in class j, x+,j\textbf{x}_{+,j} and x−,j\textbf{x}_{-,j} represents positive samples and negative samples respectively. T refers to the number of triplet pairs. In CRL, all the minority class samples are selected as anchors.

We define easy sample as the correctly predicted sample. Choosing all the minority samples as anchors is not stable for model to learn, since it may cause problems such as pulling easy positive samples to the negative side. Examples are illustrated in Figure 3.

We propose a method to improve the sampling operation of Triplet loss with Easy Anchors LTEA\mathcal{L}_{\text{TEA}}, defined as follow:

where xeasy,j\textbf{x}_{easy,j} refers to easy minority samples in class jj, others are similar to equation 9. Easy anchors are defined as high-confident correctly predicted minority samples. The number of hard positives, hard negatives and easy anchors to be selected is determined by the hyper-parameter kk.

With LTEA\mathcal{L}_{\text{TEA}} loss, only easy samples in minority class are chosen as anchors, which pulls the hard positive samples closer and pushes hard negative samples further. As illustrated in Figure 3. Different from CRL choosing all minority samples as anchors to make rectification on feature space, our proposed method selects easy anchors based on the result of the classifier and pull all the samples to well-classified side. Also, we adopt the hard sample mining for those selected easy anchors to build the triplet loss.

4 Loss Scheduler

To train the model better, we analyze the different characteristics of the two proposed losses. Generally speaking, triplet loss targets at learning a soft feature embedding to separate different samples in feature space without assigning labels, while cross entropy loss aims to classify the samples by assigning specific labels.

Particularly for imbalanced data learning, what we want is that the system first learns an appropriate feature representation then benefits the classification. Therefore, in order to fully utilize these two properties, we design a loss curriculum scheduler f(l)f(l) to manage these two losses.

Even though we can choose any one of the schedule functions in Section 3.1, we use the composite function (Equation 4) as an example here. The model learns with the following scheduler:

where ll refers to current training epoch, LL refers to expected total training epochs. Small modifications including a hyperparameter pp ranging in $,whichisdefinedasadvancedself−learningpoint.Moreover,, which is defined as advanced self-learning point. Moreover,\epsilonistheself−learningratio.Thereasonwhywehaveanon−zerois the self-learning ratio. The reason why we have a non-zero\epsilon$ here is that even though in self-learning stage, the model still needs to maintain the feature structure learned from in the previous stages.

In the early stage of training, a large weight is initialized to the triplet loss LTEA\mathcal{L}_{\text{TEA}} for learning soft feature embedding and decreases through time in respect to the scheduler function. In the later stage, the scheduler assigns a small impact on LTEA\mathcal{L}_{\text{TEA}} and system emphasizes more on the Dynamic Selective Loss LDSL\mathcal{L}_{\text{DSL}} to learn the classification. Finally, when it reaches the self-learning point, no ‘teacher’ curriculum scheduler is needed. The model automatically finetunes the parameters until convergence.

5 Generalization of DCL Framework

To handle the imbalanced data learning problem, we propose the Dynamic Curriculum Learning framework. Revisiting the overall system, DCL consists of two-level curriculum schedulers. One is for sampling g(l)g(l), and another is for loss learning f(l)f(l). We can find that several state-of-the-art imbalanced learning methods can be generalized from the framework with different setups for the schedulers. The correspondings are listed in Table 1. Selective Learning does not contain metric learning and only uses a fixed target distribution. CRL-I does not contain a re-weight or re-sample operation and only uses a fixed weight for metric learning.

Experiments

CelebA is a human facial attribute dataset with annotations of 40 binary classifications. CelebA is an imbalanced dataset, specifically on some attributes, where the sample imbalance level (majority class rate-50%\%) could be up to 48. The dataset contains 202,599 images from 10,177 different people.

RAP is a richly annotated dataset for pedestrian attribute recognition in real surveillance scenario. It contains 41,585 images from 26 indoor cameras, with 72 different attributes. RAP is a highly imbalanced dataset with the imbalance ratio (minority samples to majority samples) up to 1:1800.

CIFAR-100 is a natural image classification dataset with 32×3232\times 32 pixels. It contains 50,000 images for training and 10,000 images for testing. It is a balanced dataset with 100 classes. Each class holds the same number of images.

2 Evaluation Metric

For CelebA dataset and RAP dataset, following the standard profile, we apply the class-balanced accuracy (binary classification) on every single task, and then compute the mean accuracy of all tasks as the overall metric. It can be formulated as following:

where mAimA_{i} indicates the class-balanced mean accuracy of the ii-th task, with TPiTP_{i} and PiP_{i} indicating the count of predicted true positive samples and positive samples in the ground truth for the ii-th task while TNiTN_{i} and NiN_{i} refers to the opposite. ∣C∣{|C|} is the number of tasks.

For CIFAR-100 dataset, since each class holds the same number of instances, class-balanced accuracy equals to class-biased accuracy.

3 Experiments on CelebA Face Dataset

Network Architecture We use DeepID2 as the backbone for experiments on CelebA for a fair comparison. DeepID2 is a CNN of 4 convolution layers. All the experiments listed on table 2 set DeepID2 as backbone. The baseline is trained with a simple Cross-Entropy loss. Since CelebA is a multi-task dataset, we set an independent 64D feature layer and a final output layer for each task branch. For each branch, it considers its own current and target distribution and generates single attribute loss (Equation 12). Then we sum them up for backpropagation in a joint-learn fashion.

Hyper-Parameter Settings We train DCL at learning rate of 0.003, batch size at 512, training epoch at 300 and weight decay at 0.0005. Horizontal Flip is applied during training. Specifically, we set sampling scheduler to convex function in Equation 1, loss scheduler to composite function in Equation 12 with advanced self-learning point pp to 0.3, and kk in LTEA\mathcal{L}_{TEA} (Equation 10) to 25. The margin is set to 0.2.

Time Performance We train all the models with TITAN XP GPU. Compared to the baseline DeepID2 which takes 20 hours to train, DCL training framework spends 20.5 hours to converge (only 0.5 hour more on sampling and loss calculation) under the same 300 epochs.

3.2 Overall Performance

We compared our proposed method DCL with DeepID2 , Over-Sampling and Down-Sampling in , Cost-Sensitive , Selective Learning (SL) , CRL, LMLE and CLMLE.

Table 2 shows the overall results on CelebA. The baseline of our evaluation is the general face classification framework DeepID2 with standard cross entropy loss, where we achieve around 8%\% performance improvement. Compared to the recent advanced method, our method outperforms 3.12%\% to Selective Learning, 2.45%\% to CRL-I, 5.22%\% to LMLE and 0.27%\% to CLMLE, respectively. Specifically, LMLE/CLMLE methods are sample-clustering based methods. However, one sample is usually bundled with multiple different attributes. It is challenging to handle all the aspects of different attributes in constructing quintuplet (four-samples). In our proposed DCL method, it treats different attributes individually based on their own distributions and the triplet loss is also defined in attribute-level so that it can be easily expanded to multiple attributes learning problem. Besides, our method is computational efficient with minimal extra time cost compared to the cross-entropy loss. In LMLE/CLMLE, a computational expensive data pre-processing (including clustering and quintuplet construction) is required for each round of deep model learning. To create a quintuplet for each data sample, four cluster- and class-level searches are needed.

3.3 Effect of Data Imbalance Level

In this part, we show the performance gain of each attribute respecting to the data imbalance level compared with the baseline method DeepID2 in Figure 4. In the figure, red, blue, green curves indicate DCL, CRL, CLMLE respectively. The horizontal axis indicates the imbalance level and the vertical axis is the performance gain to the baseline for each method. We can observe that our proposed DCL method stably improves the performance across all the attributes while others degrade in some. Specifically, CRL is poor on attribute ‘Heavy Makeup’(-4%\%: level-11) and CLMLE is poor on attributes ‘Wear Necklace’(-1%\%: level-43)/‘Blurry’(-2%\%: level-45)/‘Mustache’(-6%\%: level-46). Our method achieves remarkable performance over the other two methods when the data is largely imbalanced, which results from the target distribution transition from imbalanced to balanced in sampling strategy. In the later stage of learning, the model focuses more on minority class while still keeps an appropriate memory for the majority class. The most significantly improved attribute is ‘Blurry’, with imbalance ratio 45 (8%\% performance gain to CRL, 21%\% to CLMLE). Considering all these three methods adopt the same backbone, results show the advantage of the DCL training framework.

3.4 Ablation Study

There are several important parts in the proposed DCL framework, including the sampling scheduler, design of the triplet loss with easy anchor and loss scheduler. We provide the ablation study in Table 3 to illustrate the advantages of each component. Sampling scheduler (SS) aims to dynamically manage the target data distribution from imbalanced to balanced (easy to hard) and the weight of each sample in LDSL\mathcal{L}_{\text{DSL}} (Equation 7). Triplet loss with easy anchors (TL) modifies the anchor selection of triplet pair for better learning (LTEA\mathcal{L}_{\text{TEA}}). Loss scheduler (LS) controls the learning importance between LDSL\mathcal{L}_{\text{DSL}} loss and LTEA\mathcal{L}_{\text{TEA}} loss. From the table, we can see that our two important curriculum schedulers contribute a lot with performance gain to the whole system.

3.5 Effect of Scheduler Function Selection

Since we design several scheduler functions with different properties, we also include an analysis of them. The experiment setup is that we only include the selection variation for sampling scheduler, disable the metric learning with easy anchor and loss scheduler to avoid the mutual effect. In Table 4, remember that the target distribution of methods (2-5) is nonlinearly adjusted by the power operation (Eq. 6) of the scheduler function value. For method (*), the distribution is simple linearly decreasing to 1 at the end of the training. We can observe that method (*) is much worse than others. Also, the convex function is a better selection for sampling scheduler. According to the definition of scheduler function which indicates the learning speed, it interprets that it is better for the system to learn the imbalanced data slowly at the very beginning of training and then speed up for balanced data learning.

4 Experiments on RAP Pedestrian Dataset

Network Architecture We use ResNet-50 as the backbone for our proposed method. For each attribute, we set an extra feature layer of 64-dimension and a final output layer. Our baseline in table 6 is a ResNet-50 model trained with Cross Entropy loss in a multi-task learning framework.

Hyper-Parameter Settings We train DCL with batch size 512, learning rate 0.003, decay at 0.0005 and the epoch at 300. Horizontal Flip is applied during training. Specifically, we set sampling scheduler to convex function in Equation 1, loss scheduler to composite function in Equation 12 with advanced self-learning point pp to 0.3, and kk in LTEA\mathcal{L}_{TEA} (Equation 10) to 25.

4.2 Overall Evaluation

For overall evaluation, we include several the state-of-the-art methods that been evaluated in this dataset, including Deep-Mar , Inception-v2 , HP-net , JRL , VeSPA and LG-Net . Table 5 indicates the average class-balanced mean accuracy (mA) for each method in RAP dataset. The 1st/2nd best results are highlighted in red/blue, respectively. We can see that our proposed DCL method outperforms the previous best one (LG-Net) with a large performance gain (5%\%). In term of computational complexity, methods like LG-Net and HP-net apply classwise attention to their model, so their methods take more resource in training and inference. Our proposed method is an end-to-end framework with small extra cost.

4.3 Effect of Data Imbalance Ratio

Different from the definition of imbalance level (majority class rate-50%\%) in CelebA, imbalance ratio (1:x) in RAP is the ratio of minority samples to majority samples. As we mentioned, there are 70 attributes in this dataset and the imbalance ratio is up to 1:1800. Therefore, to show the advantage of our method for imbalanced data learning, we group attributes into three categories concerning imbalance ratio and compare the average mA with the baseline method. The baseline is a ResNet-50 model trained with cross-entropy loss. From Table 6, we can observe that for group 1 with attribute imbalance ratio from 1∼\sim25, our method outperforms 3.8%\% to the baseline. When the data is more imbalance distributed in group 2 with ratio 25∼\sim50 and group 3 with ratio >50, DCL achieves 15.0%\% and 17.5%\% performance gain, respectively. This result demonstrates that our proposed DCL method indeed works effectively for extremely imbalanced data learning.

5 Experiments on CIFAR-100 Dataset

To validate the generalization ability of our method, we conduct the experiment on a balanced dataset CIFAR-100 with our learning framework. In this balanced case, methods in Table 2 are the same to the baseline method with cross-entropy loss. Also, there is no performance report of LMLE/CLMLE for generalization check. Therefore, we compare the results with the baseline and CRL in Table 7. From the result, we can see our DCL method outperforms the baseline and CRL with +3.4%+3.4\% and +2.2%+2.2\%, respectively. Compared to CRL, our proposed triplet loss with easy anchor stabilizes the training process. Combined with the loss learning scheduler, DCL makes a better rectification on feature space to provide a better representation for the general classification.

Conclusion

In this work, a unified framework for imbalanced data learning, called Dynamic Curriculum Learning (DCL) is proposed. For the first time, we introduce the idea of curriculum learning into the system by designing two curriculum schedulers for sampling and loss backward propagation. Similar to teachers, these two schedulers dynamically manage the model to learn from imbalance to balance and easy to hard. Also, a metric learning triplet loss with easy anchor is designed for better feature embedding. We evaluate our method on two widely used attribute analysis datasets (CelebA and RAP) and achieve the new state-of-the-art performance, which demonstrates the generalization and discriminative power of our model. Particularly, DCL shows a strong ability for classification when data is largely imbalance-distributed.

References