Deep Learning

Label Smoothing

Softening hard one hot targets to prevent neural networks from becoming overconfident.

🟡 intermediate4 min readregularization
Label Smoothing is a regularization technique that replaces hard binary targets with softened probability distributions. Standard cross entropy loss uses hard one hot targets like 1.0 for the correct class and 0.0 for all other classes, forcing the network to output infinite logit values to reach zero loss. Label smoothing softens targets to values like 0.9 for the correct class and redistributes 0.1 uniformly across incorrect classes, improving model calibration and generalization.

What is Label Smoothing?

In standard classification tasks, target labels are represented as hard one hot vectors:

  Hard One Hot Target (Class 2):  [ 0.0,  1.0,  0.0,  0.0 ]

To output a probability of 1.0 for Class 2 using Softmax:

$$\text{Softmax}(z_2) = \frac{e^{z_2}}{\sum e^{z_j}} \to 1.0 \implies z_2 - z_j \to +\infty$$

To make probability reach 1.0, the network must push logit $z_2$ to positive infinity relative to other classes.

This forces weight magnitudes to grow endlessly large during training, making the network overconfident and prone to severe overfitting.

How Label Smoothing Works

Label Smoothing softens hard target vectors by blending them with a uniform probability distribution:

  Label Smoothed Target (epsilon = 0.1):  [ 0.025,  0.925,  0.025,  0.025 ]

Formula for smoothed target $y_k$:

$$y_k = (1 - \epsilon) \cdot y_k^{\text{hard}} + \frac{\epsilon}{K}$$

Now the network only needs to learn finite logit differences (for example, target probability 0.925 instead of 1.0), preventing weights from growing endlessly.

Key Benefits

  1. Prevents Overconfidence: Keeps logits bounded, producing realistic confidence probabilities on test data.
  2. Improves Model Calibration: Predictions better reflect true real world accuracy.
  3. Better Generalization: Standard trick used when training Vision Transformers, EfficientNets, and Machine Translation models.

When to Avoid Label Smoothing

Do NOT use label smoothing if you plan to use the trained model as a Teacher for Knowledge Distillation.

Label smoothing flattens logit differences among non target classes, stripping away fine grained information about which incorrect classes are most similar to the target.

Say this out loud

Label Smoothing replaces hard one hot targets like 1.0 with softened targets like 0.9, distributing remaining probability uniformly across wrong classes. This prevents Softmax logits from growing infinitely large, stopping the model from becoming overconfident and improving model calibration on unseen test data.

Followups to expect

  1. How does Label Smoothing impact clustering in hidden feature space? Muller et al. (2019) showed that label smoothing forces representations of samples in the same class to cluster tightly around equidistant cluster centers.
  2. What is Temperature Scaling for Calibration? A post processing technique that adjusts logit scale using a validation temperature parameter T to calibrate confidence probabilities without retraining model weights.

Check yourself

Question 1 of 3

Why does training with hard one hot targets (like 1 for correct class, 0 for wrong classes) cause neural networks to become overconfident?

More in Deep Learning

See all →
Activation Functions4 minDropout4 minBackpropagation5 min