{'fraction_non_alphanumeric': 0.034725646263295065, 'fraction_numerical': 0.014439670352891456, 'mean_word_length': 4.744487153550476, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Learning Soft Labels via Meta Learning

One-hot labels do not represent soft decision boundaries among concepts, and hence, models trained on them are prone to overfitting. Using soft labels as targets provide regularization, but different soft labels might be optimal at different stages of optimization. Also, training with fixed labels in the presence of noisy annotations leads to worse generalization. To address these limitations, we propose a framework, where we treat the labels as learnable parameters, and optimize them along with model parameters. The learned labels continuously adapt themselves to the model's state, thereby providing dynamic regularization. When applied to the task of supervised image-classification, our method leads to consistent gains across different datasets and architectures. For instance, dynamically learned labels improve ResNet18 by 2.1% on CIFAR100. When applied to dataset containing noisy labels, the learned labels correct the annotation mistakes, and improves over state-of-the-art by a significant margin. Finally, we show that learned labels capture semantic relationship between classes, and thereby improve teacher models for the downstream task of distillation.


Introduction
In a general setting, training machine learning models for classification involves optimizing a mapping between input and fixed one-hot labels.
Having fixed one-hot labels during training can be sub-optimal for multiple reasons. First, one-hot labels do not reflect the similarities between semantically related classes. Therefore, training models using them can lead to hard decision boundaries that do not generalize well (over-fitting). Second, the annotated labels might contain noise, training on which can degrade performance [3]. Various techniques have been proposed to tackle these problems separately. For example, in label smoothing [14,24], the one-hot labels are converted into soft labels by uniformly distributing a small amount of probability mass on non-target classes, thereby providing regularization for learned decision boundaries. In [21], an auxiliary neural network is used to assign weights to inputs, where the method ignores the noisy samples by assigning smaller weights to them.
Obtaining the right labelling of a dataset to address the two problems mentioned above is a hard task [10]. One can generate soft labels using distillation [5], but the labels obtained at convergence might not be optimal for all stages of training. Similarly, in settings where training data may contain wrong annotations, the learning process should ideally correct them, without relying on human intervention. In our work, we address these concerns by proposing an optimization framework common to both, supervised and noisy data settings. Under our framework, the labels are treated as learnable parameters, and are learned along with the model parameters (see Figure 1). More specifically, throughout training, the framework looks at the performance of the model on a held-out set, and updates the labels on the training set, such that when the model is trained with these labels, it performs well on the held-out set. As a result, the learned labels are dynamic and adapt to different stages of training, leading to improved generalization. The main contributions of our work are: 1. We introduce a meta-learning framework where the labels of training set are treated as learnable parameters and are learned along with the model parameters. Labels are learned using gradient descent, and continously adapt to the model state during optimization.
2. When applied in supervised setting, training with dynamically learned labels improves over competitive baselines on CIFAR100 and CIFAR10 dataset across multiple architectures. 3. We show that learned labels capture semantic relationship among classes, and training with them leads to better teacher models for the downstream task of distillation. Further, we show that these labels provide a competitive alternative to knowledge distillation, as they are directly transferable to other architectures.
4. When used in noisy data setting, our framework corrects annotations mistakes in the dataset, and outperforms the state-of-the-art by significant margin. Figure 1: Left: Our method treats the labels as learnable parameters, and learns them along with the model parameters. Right: In supervised setting, our method starts with one-hot labels, and captures shared concepts specific to the instance. In noisy data setting, our method learns to correct the labels.

Learning Dynamic Soft Labels via Meta Learning
As mentioned earlier, in contrast to using fixed one-hot labels for model optimization, our method learns dynamic soft labels that adapt to model state during training. In this section, we formalize our method and present the framework by first showing how to learn class labels, which are unique to every class in the dataset (see Section 2.1). Next, we show how our method can be extended to learn instance labels, which are unique to every instance in the dataset (see Section 2.2).

Class labels
At different steps of optimization, certain classes may be more prone to over-fitting than others. So, different degrees of regularization may be required for them. We begin by considering an adaptive smoothing parameter unique to each class, such that the class label is obtained by smoothing the one-hot labels proportional to this parameter. The parameters regularize each class differently, thereby preventing over-confident model predictions [15].
To formalize, given a training set with N data points and c classes, let x i ∈ R d denote a single data point and y i ∈ {1, ..., c} denote the corresponding target class. Let α t ∈ R c represent smoothing parameters for all classes at step t of optimization, where α t k is the smoothing parameter for class k. Let p t i,k be the probability mass on class k for instance i at step t. The effective class label p t i ∈ R c is a probability distribution defined as follows: Let, f (x, θ t ) and θ t denote the model and model's parameters at step t respectively. Let L train (x i , p t i ; θ t ) denote the cross-entropy loss between model prediction and class label p t i for data point i. For sake of explanation, we denote L train (x i , p t i ; θ t ) as L train i (α t yi ; θ t ), as p t i is a function of α t yi . Our goal is to solve for optimalθ by minimizing the loss on the training set.
Here,θ is a function of α t . Note, if ∀t α t = 0, Eq. 1 is equivalent to standard classification loss with one-hot fixed targets. But, here, the best choice of α t is not known apriori. We cannot optimize α t and θ t using the loss objective on the same data points, because it can lead to degeneracy. For instance, Eq. 2 allows for a local minima where the class labels and model predictions converge to each other and can be away from the ground truth. To avoid this issue, we turn to meta-learning, where we use a training set to optimize θ t , and a meta set to optimize α t . To save the computational cost of unrolling the feed-forward graph through multiple time steps, we use a one-step look ahead approach to estimate the gradient of α t on meta set.
Meta learning for class labels: We sample a mini-batch with n instances from the training set, and simulate a one step look-ahead SGD update on model parameters (θ t+1 * ) as a function of α t (see Eq. 3). Here, λ θ is the learning rate for model parameters. Next, the one step look-ahead update is used to compute the loss on meta set L meta (θ t+1 * ). In our experiments, we use the cross entropy loss between the model predictions and labels in the meta set. This loss is used to compute the meta-gradient on the smoothing parameters (see Eq. 4): Using the meta-gradient (in Eq. 4), we update the smoothing parameter for each class using the first order gradient update rule (see Eq. 5). The updated value α t+1 is then used to update the model parameters (see Eq. 6). Here, λ α is the learning rate for smoothing parameters of all classes.
Our method is summarized in Algorithm 1. Note, if the smoothing parameters are fixed and common to all classes, our method is similar to label smoothing [24]. However, having fixed smoothing throughout training might be suboptimal. We later verify this finding in Section 3.3, where we show that when we adapt these parameters dynamically, the model prefers a higher degree of smoothing at the start of optimization, but reduces the smoothing at convergence.

Instance labels
Class labels assume a homogeneous distribution of instances within a class. Further, they allocate uniform probability on non-target classes, meaning for a given class, all non-target classes are equally likely. However, instances within a class can have varying properties. For example, in Figure 1 (right), consider an image of class Baby, where the baby is sitting on a table. The ideal soft label should have more probability mass on class Table than other non-target classes. Such instance labels could help learn softer decision boundaries via shared concepts. We use our meta-learning framework to learn such labels directly.
Formally, for a given instance x i at step t of optimization, instance labels are learnt via smoothing parameters, where α t i,k is the smoothing parameter for hypothesis class k ∈ {1, ..., c}. The instance

Algorithm 1 Algorithm for learning dynamic soft labels via meta learning
Input: Train set D train , meta set D meta , learning rate of model λ θ , learning rate of class smoothing parameters λα, max iterations T . Output: Model parameters at convergence θ T 1: Initialize model parameters θ 0 with random and α 0 with 0.

5:
{p t } ← CalculateSoftLabels(α t , y train ). 6: Compute one step update for model parameters as function of α t by Eq. (3). 7: Update α t+1 by Eq. (5). 8: Update θ t+1 by Eq. (6). 9: end for i,k as shown in Eq. 7, the meta gradient on an instance is proportional to the dot product of the gradient of training loss at the i th sample at step t, and the gradient of the meta loss over all samples in the meta set at step t + 1. Therefore, a hypothesis class whose gradient aligns with the gradients on the meta set will obtain a higher probability mass. This allows a more informed allocation of probability mass on non target classes.
Another advantage of learning instance labels is in the noisy data setting, as our framework can perform label correction. More specifically, the incorrect hypothesis class will misalign with the meta-gradients in Eq. 7. So, under our algorithm, the probability mass over incorrect class will reduce, and the probability mass on correct class will increase during optimization (see Section 3.5).

Implementation details
To show the general applicability of our method, we evaluate our method on the CIFAR100 and CIFAR10 datasets [8] using multiple architectures viz. WideResNet (WRN) [29], VGG16 [22], ResNet18 [4], and AlexNet [9]. Both datasets contain 50,000 images in the training set, and 10,000 images in the test set. Each image in CIFAR100 belongs to one of 100 classes, and each image in CIFAR10 belongs to one of 10 classes. We use 20% of the training set as common held-out data for both validation set (tune hyper parameters) and meta set. The class and instance labels are optimized using a 5-fold cross validation approach. The final performance is reported on the full training data by averaging the learned dynamic labels across each fold. The label parameters do not change the overhead at inference, as they are only present during training.
Unless stated otherwise, the following hyper-parameters are used for our meta-learning approach. Batch size for training and meta set is fixed to 128 and 256. We use separate optimizers for learning soft labels and model parameters, and both are optimized using stochastic gradient decent (SGD). For class labels, we ensure a valid probability distribution by clamping the smoothing parameters between 0 and 1. For instance labels, we use the softmax function to ensure a probability distribution over all classes. We search in the range of {0.3, 0.5, 0.7, 0.9} for initializing the target classes for soft label parameters. The remaining probability mass is used to uniformly initialize the non target classes. We search in the range of {25, 50, 75, 100, 150, 200} for the learning rate of soft label parameters. These parameters do not use any learning rate schedule. For all experiments, we report the mean and standard deviation over 3 runs.

Image classification in supervised setting
In this section we demonstrate the efficacy of our method when applied to the task of image classification in the supervised setting. We evaluate our framework on CIFAR100 and CIFAR10 dataset using ResNet18 [4] and VGG16 [22] architectures, and compare it with baseline which uses fixed one-hot labels. As shown in Table 8, learning class labels on CIFAR100 improves over baseline by 1.8% and 0.4% for ResNet18 and VGG16, respectively. Learning instance labels lead to a gain of 2.1% and 0.8% for ResNet18 and VGG16, respectively. This result supports our hypothesis: instance labels relax the uniform prior over non-target classes, giving it an advantage to account for instance specific features. The gains over baseline are higher in ResNet18 compared to VGG16. We attribute this to ResNet18 being more prone to overfitting, and thereby benefiting more from dynamic regularization of soft labels. On CIFAR10, similar to CIFAR100, we improve over baseline. However, there are fewer, but more distinct classes, and so the gains are diminished.   Table 2: On CIFAR100, our method of learning dynamic labels outperform common methods that use fixed labels.
Comparison with other methods: In Table 2, we compare our approach to methods that use fixed labels, but incorporate other strategies for improving generalization. Confidence penalty [15] uses one-hot labels to optimize the model parameters, but regularize the model predictions by penalizing low entropy distributions. Label smoothing [24] regularizes over-confident predictions by optimizing soft labels, that remain fixed throughout optimization. These soft labels are obtained by modifying the one-hot labels to allocate a small amount of uniform weights to non target classes. In contrast, our method takes into account the shared concepts at different stages of training, and dynamically regularizes the model for softer decision boundaries. For similar reasons stated above, we obtain diminished gains on CIFAR10 (reported in Supplementary).

Analysis of dynamic labels
In the previous section, we establish that dynamic soft labels improve generalization. In this section, we study the different components of our method and highlight their importance.  Importance of dynamic labels: To study the importance of trajectories of labels for generalization, we train a model in two settings (1) dynamic label trajectories updated at each iteration, and (2) fixed labels taken from setting (1) at convergence. As shown in Figure 3, the model trained with fixed labels at convergence performs worse. This result empirically establishes that we need different degrees of smoothing (hence, dynamic labels) throughout optimization to improve generalization.
Dynamic labels are repeatable: To perform a qualitative evaluation of the trajectories, we visualize the class labels in Figure 2 (middle). For CIFAR100 using ResNet18, we pick three random classes, and plot the probability mass on target class over the course of training (mean and standard deviation over three runs). The trajectories are dynamic, and adapt differently for these classes. More importantly, low standard deviation implies the learned trajectories are highly repeatable, and intrinsic to the dataset and the model.
Dynamic labels provide regularization: In Figure 2 (left), we plot the meta set accuracy of three classes during optimization, which aligns with our hypothesis that certain classes are harder to optimize, and hence, need to be regularized differently. In Figure 2 (middle), we see that the target class probability (i.e. the effective smoothing due to the class label) and its meta set accuracy are highly correlated. E.g. the class depicted in green has the lowest accuracy, and therefore the highest smoothing. As the model performance improves, the smoothing reduces. This dynamic behavior is important for generalization, but is not possible in common methods which optimize model parameters with fixed labels [15,24] or a fixed degree of regularization [23].
Instance labels capture instance properties: Instance labels relax the assumption that non-target classes are equally likely. Therefore, this method can learn more detailed softer decision boundaries, which helps to capture instance specific properties. As shown in Figure 2 (right), our method learned different instance labels for two samples of the same class Baby. For example, in the image of a baby sitting on a table, the second-most probability mass is on class Table. Similarly, the learned soft labels also account for similar concepts between classes. For example, in the images of an apple, the most probable classes are similar to target class i.e. pear and orange.

Improving knowledge distillation using instance labels
Distillation [5] is a method to transfer the generalization ability of a large (teacher) model into a compact (student) model, via the information present in the predictions of the teacher model. More precisely, the predictions from a pretrained teacher model are softened using a temperature parameter, and used as targets for training the student model. Intuitively, methods such as label smoothing which regularize the models against making over-confident predictions, should help to improve the teacher models, thereby improving the downstream task of distillation. However, recent work [14] has shown that training teacher models with label smoothing leads to inferior student models, as the instance specific information is lost. In contrast, in this section, we show that training teacher models with dynamic labels makes them more suitable for distillation.  Table 4: Performance of distillation from ResNet18 to AlexNet on CIFAR100 using instance labels.
For this study, we replicate the setting in [14], and use ResNet18 as teacher model and AlexNet as student model. We compare with knowledge distillation using one-hot targets and label smoothing. We use instance labels in two settings (1) Similar to [5], we use predictions (referred as Ours (Model) in Table 4) from a teacher model trained with instance labels, as targets for the student, and (2) we use the converged instance labels (referred as Ours (Labels) in Table 4) as targets for the student. In all experiments, the temperature is tuned by searching in the range of [0, 10] with increments of 0.25.
First, we replicate the findings of [14] in Table 4, and verify that training with label-smoothing leads to worse downstream performance for distillation. As shown in [14], use of a uniform-prior in label smoothing pushes all classes equally far, destroying the semantic similarity between classes and instances. In contrast, our method treats classes heterogeneously, and learns label smoothing specific to an instance (see Figure 2 (right)). Accordingly, as shown in Table 4, when we distill knowledge from a teacher model trained using our method, we outperform the teacher trained using label smoothing by a significant margin. Our teacher model trained with instance labels is also less sensitive to temperature tuning, and performs well even without temperature scaling. This is expected as unlike distillation with one-hot targets where the predictions are softened at convergence, we optimize using soft labels at each step of optimization. Now that we have established the benefit of training teacher models with instance labels, we evaluate the efficacy of instance labels obtained at convergence, for the purpose of distillation. As shown in Table 4, we achieve comparable performance even when we use soft labels instead of model predictions as targets for distillation. This shows that the converged labels capture the dark knowledge [5] and can be used for label distillation. We expect this performance to further improve by using dynamic label trajectories, instead of static labels at convergence. However, due to difference in factors like learning rate schedule, and number of iterations, this is not straight-forward. We leave this for future exploration.  Instance labels are generalizable across architectures: From the above results, we would expect that instance labels depend more on the underlying data than on the architecture they were trained on. In this section, we show that instance labels from one architecture can be used to train other architectures. More specifically, we use the labels from VGG16 and ResNet18 at convergence, perform temperature scaling on them, and use them to train other architectures. As observed in Table 5, using labels from other architectures outperforms the baseline by a significant margin. Interestingly, labels trained with ResNet18 generally perform better compared to labels trained using VGG16. We attribute this to the capacity of the model, which we suppose could play a crucial role in learning better labels.

Image classification in a noisy label setting
As mentioned earlier, an ideal framework to learn from noisy data should not only ignore incorrectly labelled instances, but also be able to correct labels so as to learn from them. As shown in Figure 3, instance labels shift the probability mass across classes during the course of optimization, thereby correcting noisy instances. In this section, we show how our method performs in a noisy label setting by correcting incorrect samples, and how this compares with the existing state-of-art. Figure 3: Examples of noisy instances in CIFAR100 that were corrected using our framework.
To create the noisy data setting, and to compare with the relevant state-of-art, we follow the common settings as mentioned in [7,19,21]. Here, the target label of each instance is independently changed to a uniformly random class with probability p. This p is called the noise fraction, and we show results with p=[0.2, 0.4, 0.6 and 0.8]. The target labels in the validation and meta set are, however, not changed. We maintain the same setting in [7,21] and use WideResNet-28-10 architecture, and 2% training set as clean meta data. We report the results on CIFAR100 and CIFAR10 in two settings -(1) Setting A as in [21], and (2) Setting B as in [20]. Figure 4: Instance labels correct noise in CIFAR100 by shifting the probability mass on the correct class during training. Top-5 accuracy changes from 65% at start of training to 90% at convergence.
Current state-of-art approaches assign a weight to each instance in the training set, where ideally the noisy instances should be down-weighted over the course of training (see Section 4. However, instance labels have an additional advantage in that they are able to change the target labels, there-by correcting the noisy instances. For example, at convergence, our method corrected 7% of the noisy samples of CIFAR100 in the 40% noise setting (see Figure  4), reaching 33% noise at top-1 at convergence. Further, we observe that this method reduces the entropy of the noisy samples which it cannot correct, by reducing the probability mass on the incorrect target classes. We leverage this property to learn an implicit curriculum over the instances, by weighing each instance by the entropy of its label. In setting A [21], our method outperforms the current state-of-art in CIFAR10 by 1.1% at 40% noise, and by 1.6% at 60% noise. On CIFAR100, we outperform the state-of-art by 2% at 40% noise, and 0.9% at 60% noise (see Table 6). Finally, in setting B [19], we outperform state-of-art in CIFAR100 by 1.2% at 20% noise, and 0.9% at 40% noise. In the extreme noise setting at 80%, our method achieves comparable performance to the current state of art (see Table 7).
[2] embed labels using word embeddings in a Euclidean space, and computes similarities (soft-labels) based on dot-product in this space. Their method is limited to settings where labels are comprised of natural words. [11] argue against using a single smoothing across entire dataset, and instead cluster the data and propose a heuristic to set the smoothing parameter for data points in each cluster. Our work does not rely on clustering in a feature space, and learns optimal soft-labels for each instance via meta-learning. [12] also use meta-learning to learn optimal soft labels, but reset the label estimates at every epoch. On the contrary, our work treats labels as learnable parameters, that are continuously optimized throughout training (which is key to label correction in corrupt data setting). [16] is the most relevant to our proposed approach, where an auxillary teacher model is trained to assign soft targets to a student, thereby yielding dynamic soft labels. Our work does not rely on a teacher model, instead it explicitly instantiates and learns soft labels for the dataset. As a result, our method can account for the class membership of data points, and learns to regularize each class and instance separately. Also, their method is Markovian in nature, while our method benefits from the past history of optimization of the soft-labels.
Noisy data setting: In the noisy data setting, [7,21] trained an auxillary neural network using meta-learning to assign weights to samples in the mini-batch. [18] uses a held-out set to perform an online approximation of weights for samples in a minibatch. [19] introduced learnable temperature parameters per data-point, which scale the gradient contribution of each data-point. [30] use metalearning to perform a linear combination of the original labels and pseudo labels generated by DNN on the fly. The learned weights are used to cluster the data as clean or mislabelled. While these works can reduce the contribution of noisy instances, they cannot correct the incorrect labels. In contrast, our framework is able to correct the labels of noisy instances, and outperforms these methods. [25,28] propose a framework for correcting noisy annotations in the dataset. They update model parameters and labels in an alternate manner using the training dataset. However, since the model parameters and labels are updated on the same data, they rely on hand-crafted heuristics to prevent degenerate solutions. While they obtain promising results in low noise setting, these heuristics fail to converge in presence of high annotation noise [28]. Our method does not rely on any heuristic, instead we use the meta-learning constraint, and outperform state-of-the-art at all levels of noise.

Conclusion
In this work, we have proposed a meta-learning framework under which the labels are treated as learnable parameters, and are optimized along with model parameters. The learned labels take into account the model state, and provide dynamic regularization, thereby improving generalization. We learn two categories of soft labels, class labels specific to each class, and instance labels specific to each instance. In case of supervised learning, training with dynamically learned labels leads to improvements across different datasets and architectures. In presence of noisy annotations in the dataset, our framework corrects annotation errors, and improves over the state-of-the-art. Finally, we show that teacher models trained with dynamically learned labels improves the downstream task of distillation.   Table 9: Hyperparameter setting for CNN architectures. We do not use dropout.

Hyperparameters for dynamic soft labels
The hyperprameters are tuned on a single cross validation fold using 20% training data as held-out data. For class labels, we use a learning rate search grid of [1e-2, 3e-2, 1e-1, 3e-1, 1, 3]. For instance labels, we use a learning rate search grid of [5,10,25,50,75,100]. For initialization of soft labels, we use a search grid of [0.3, 0.5, 0.7, 0.9] for both, class and instance labels. This initialization value is used to initialize the target class probability. The non-target class is initialized with a uniform distribution using the remaining probability.