The source’s Step-3 example: five classes, logits [2.0, 1.0, 0.1, −1.0, 3.0], true class 5 (index 4). Run softmax, read the loss, take the gradient — and then soften the targets.
SOFTMAX
e^z = [7.3891, 2.7183, 1.1052, 0.3679, 20.0855] sum = 31.6660
p = [0.2333, 0.0858, 0.0349, 0.0116, 0.6343] Σp = 1.0000
HARD TARGET (one-hot, y = class 5)
CCE = −ln 0.6343 = 0.4552
grad = p − y = [+0.2333, +0.0858, +0.0349, +0.0116, −0.3657]
sum = 0.0000 "probability moves between classes, never appears"
LABEL SMOOTHING, α = 0.1, C = 5 classes
t = [0.02, 0.02, 0.02, 0.02, 0.92] (1 − α + α/C = 0.92, α/C = 0.02)
smoothed loss = −Σ tᵢ ln pᵢ = 0.6532 ← higher than the hard loss, by design
grad = p − t = [+0.2133, +0.0658, +0.0149, −0.0084, −0.2857]
the target is asked for 0.92, not 1.00 — a finite, reachable demand
the floor of the smoothed loss is the target's entropy, H(t)
5 classes: −(4 × 0.02 ln 0.02 + 0.92 ln 0.92) = 0.3897
10 classes: −(9 × 0.01 ln 0.01 + 0.91 ln 0.91) = 0.5003
a model can never drive a smoothed loss to zero — and no longer wants to
WHY THE CAP MATTERS, 10 classes
hard target: to output 0.999 against 0.0001 on the others, the logit gap must be
ln(0.999 / 0.0001) ≈ 9.21 nats — and exactly 1.0 is unreachable at any gap
smoothed: 0.91 against 0.01 needs ln(0.91 / 0.01) = ln 91 ≈ 4.51 nats
smoothing more than halves the gap it fights for
Label smoothing is a regularizer, not a lie: it says “be very confident, but not infinitely confident.” The model still puts the true class far ahead — it just stops spending capacity pushing logits toward infinity, which improves calibration and makes the network less brittle when the test distribution shifts. It also explains why the smoothed loss never reaches zero: the floor is the entropy of the softened target itself (0.50 in the ten-class case).