Homework 1, questions 1.3.2–1.3.3, with n classes. Drag a logit up or down; pick a target y, and click a class name to make it the true class. The arrows show which way gradient descent moves each logit.
With the homework’s notation, the target is a distribution y and the model’s prediction is p = softmax(z). The KL divergence measures how far p is from y; it splits into two sums, one of which does not involve p at all:
That is the bar on the right: the grey part, H(y), is fixed by the target; only the pink KL part responds when you drag the logits. So minimizing cross-entropy and minimizing KL are the same problem, and their gradients are equal. With a one-hot target H(y) = 0, only one term of the sum survives, and cross-entropy is the negative log-likelihood of the true class, −log ptrue. With a smoothed or blended target the grey part is not zero, so the loss can never go below it: that floor is the target’s own uncertainty.
Question 1.3.3 asks for ∂CE/∂z. Putting softmax’s Jacobian (softmax) through the chain rule, everything cancels to
That is the arrow on each logit, drawn as the descent step −(pi − yi): a class the model over-predicts is pushed down, one it under-predicts is pushed up, and the push is exactly the size of the error, never damped by a flat slope. That is why cross-entropy trains where squared error on the same outputs stalls (squared error vs. cross-entropy). The readout checks the formula against finite differences of the loss itself. Homework 2.1’s binary cross-entropy (task 3.4) is the n = 2 case with a sigmoid: −[y log p + (1 − y) log(1 − p)], gradient p − y on its one logit.
Write the margin of the true class as m = ztrue − log Σj≠true ezj (for two classes, just z1 − z2). Then, for any number of classes, the one-hot cross-entropy is exactly log(1 + e−m): the logistic curve in the lower plot. It falls forever but never reaches zero, so gradient descent keeps widening the gap, driving ptrue toward 1 and the logits toward infinity. Press Keep stepping with a one-hot target and watch the margin marker walk off to the right. Hinge loss, by contrast, is satisfied at m = 1, and 0-1 loss has no gradient anywhere.
Label smoothing gives the true class 1 − ε + ε/n and every other class ε/n. Now the loss has a minimum where p = y exactly, and that takes only a finite gap between the logits:
In terms of the margin, that is m* = log[(1 − ε + ε/n)/(ε − ε/n)], the gap less log(n − 1). The dashed curve is the smoothed loss with the other logits held equal; its lowest point is marked, and stepping now settles there. So smoothing is a regularizer on the output: it forbids certainty. Mixup’s blended targets do the same from the data side, asking for 60% cat and 40% dog on an image that is 60% cat and 40% dog.