The explanation follows the equations in Section 7 of the original paper. Let K be the number of classes, y the correct class of a training example x, and zk the model outputs (logits).
- The model's prediction is the logits converted to probabilities with softmax.
p(k)=∑i=1Kexp(zi)exp(zk)
- The ordinary target label q is one-hot (δk,y is 1 when k=y and 0 otherwise).
q(k)=δk,y
- Mix it with a distribution u(k) fixed independently of the data, using the smoothing strength ε. In the paper's experiments, u is the uniform distribution u(k)=1/K.
q′(k)=(1−ε)δk,y+εu(k)=(1−ε)δk,y+Kε
- Use the cross-entropy between the smoothed label q′ and the prediction p as the loss.
ℓ=−k=1∑Kq′(k)logp(k)
As a result of step 3, the target for the correct class becomes 1−ε+ε/K and the target for the other classes becomes ε/K. In the example in the figure above (K=5, ε=0.1), the correct class gets 0.92 and the others 0.02. The paper's ImageNet experiments (K=1000) used ε=0.1, giving 0.9001 for the correct class and 0.0001 for the others.
The loss in step 4 can be split into the sum of two cross-entropies as follows (Section 7 of the paper).
H(q′,p)=(1−ε)H(q,p)+εH(u,p)
The first term is the ordinary loss, and the second is a penalty measuring how far the prediction p is from the uniform distribution u. In other words, Label Smoothing is a regularizer that pulls the prediction back so it does not concentrate too much on one class, while preserving the ability to predict the correct answer.