Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Never ask for 100% certainty
A normal training target says “this is a cat, with probability 1”. The network can never quite reach 1, so it keeps pushing its scores further apart forever, becoming extremely confident, even on examples that are ambiguous or mislabelled. Label smoothing asks instead for, say, 90% cat with the remaining 10% spread over all classes. Once the network reaches that, it has no reason to become more confident.
Label smoothing is one line in most frameworks and was used to train Inception-v3, the original Transformer and many modern image models. It reduces overconfidence and makes training more tolerant of the label errors common in large datasets. It has costs too: it can hurt knowledge distillation and erase some information in the logits.
- 1. Label smoothing replaces a one-hot target by…
- 2. With hard targets, cross-entropy rewards…
- 3. Label smoothing was used in…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Target: t = (1 − ε)·onehot(y) + ε/K. For K = 4, ε = 0.2, y = 1: (0.05, 0.85, 0.05, 0.05).
- Largest target probability: 1 − ε + ε/K, which is 0.85 for K = 2, ε = 0.3.
- Loss: CE(p, t) = (1 − ε)·(−log p_y) + ε·(mean over classes of −log pₖ). The second term pushes towards uniform predictions.
- Optimal logits: the minimiser makes p = t exactly. All wrong classes share one logit, and the true class’s logit exceeds them by log((1 − ε + ε/K)/(ε/K)). For K = 10, ε = 0.1 this is log 91 ≈ 4.51. For ε = 0.01 it is 6.90, and as ε → 0 it grows without bound.
- Typical ε: 0.1.
- 1. Smoothed target for the true class, K = 4, ε = 0.2:
- 2. Optimal logit gap for K = 10, ε = 0.1:
- 3. As ε → 0, the optimal gap…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Label smoothing in code
Exercise 1.
- For K = 10 and ε = 0.1, cross-entropy was minimised exactly at a logit gap of log 91 = 4.51; moving the gap up or down by 0.1–0.5 raised the loss.
- With the gap 5 larger the loss rose from 0.500 to 0.857. Being more confident than the target is penalised.
Practice.
torch.nn.CrossEntropyLoss(label_smoothing=0.1)or Keras’label_smoothingargument.- Combine with mixup and CutMix carefully: their soft labels already smooth, and timm applies smoothing inside its Mixup.
- Do not use label smoothing for a teacher model in knowledge distillation: Müller et al. (2019) found that it erases the similarity information that distillation transfers.
- For calibration alone, temperature scaling after training is an alternative.
loss_fn = torch.nn.CrossEntropyLoss(label_smoothing=0.1)- 1. PyTorch's argument for label smoothing is in…
- 2. Label smoothing on a distillation teacher…
- 3. An after-training alternative for calibration is…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Regularisation view. The loss equals (1 − ε)·CE(p, onehot) + ε·CE(p, uniform). Up to a constant, the second term is the KL divergence from the uniform distribution to p. It penalises confident (low-entropy) predictions, a form of confidence penalty (Pereyra et al., 2017).
Representations. Müller, Kornblith and Hinton (2019) showed that label smoothing makes penultimate-layer representations of each class cluster tightly and equidistantly. This improves calibration but erases information about which wrong classes an example resembles, the information distillation relies on.
Label noise. Smoothing is related to the “forward correction” for symmetric label noise: if a fraction of labels is flipped uniformly, the expected training target is itself a smoothed vector. Lukasik et al. (2020) showed label smoothing can be competitive with noise-robust losses. It does not identify or remove wrong labels, as exercise 2 shows.
Effect on accuracy. Gains in accuracy are typically small (a few tenths of a percent on ImageNet); calibration and robustness are the main benefits.
- 1. The extra term in the smoothed loss penalises…
- 2. Label smoothing makes class clusters…
- 3. With symmetric label noise, the expected target is…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.Label smoothing with noisy labels
History.
- C. Szegedy et al. (2016) introduced label smoothing in Inception-v3.
- A. Vaswani et al. (2017) used it for the Transformer.
- G. Pereyra et al. (2017) proposed related confidence penalties.
- R. Müller, S. Kornblith and G. Hinton (2019) analysed when it helps.
- M. Lukasik et al. (2020) related it to label noise.
Exercise 2. A 2–64–64–2 ReLU network trained with Adam (3000 mini-batch steps) on 150 two-moons points, of which 20% had their labels flipped at random; tested on 2000 clean points. Means of three seeds:
| ε | clean test accuracy | test cross-entropy | probability given to the wrong label on flipped training points |
|---|---|---|---|
| 0 | 0.764 | 0.874 | 0.682 |
| 0.1 | 0.751 | 0.620 | 0.664 |
| 0.3 | 0.763 | 0.545 | 0.613 |
- Label smoothing did not change test accuracy (about 0.76 throughout).
- It limited memorisation of the wrong labels and cut the test cross-entropy by 38%. The flipped-label probability fell from 0.68 to 0.61; part of this is mechanical, since at ε = 0.3 the target itself asks for at most 0.85.
- Lesson: label smoothing tempers confidence but does not fix wrong labels; for heavy noise, use noise-robust losses, label cleaning or early stopping as well.
Label smoothing in AI, robotics and aerospace
- Large labelled datasets for perception contain label errors; label smoothing is a cheap safeguard.
- Machine translation and speech recognition systems use it routinely.
- When confidence feeds decisions, check calibration directly; combine smoothing with temperature scaling if needed.
References
- C. Szegedy, V. Vanhoucke, S. Ioffe, J. Shlens, Z. Wojna (2016). “Rethinking the Inception architecture for computer vision.” Proc. CVPR.
- R. Müller, S. Kornblith, G. Hinton (2019). “When does label smoothing help?” Advances in NeurIPS.
- G. Pereyra, G. Tucker, J. Chorowski, Ł. Kaiser, G. Hinton (2017). “Regularizing neural networks by penalizing confident output distributions.” ICLR Workshop.
- M. Lukasik, S. Bhojanapalli, A. Menon, S. Kumar (2020). “Does label smoothing mitigate label noise?” Proc. ICML.