Cross-entropy scores a predicted probability distribution against the truth. Because the true label is one-hot, almost every term drops out and the loss for one sample collapses to a single number: the negative log of the probability you gave the correct class.
loss = -(1/n) * Σ log(p[correct class])
Task: write cross_entropy(predictions, targets) where predictions[i] is a probability distribution over classes and targets[i] is the index of the correct class. Return the mean loss, rounded to 4 decimal places.
The curve is deliberately lopsided. Predicting 0.9 for the right answer costs almost nothing, while predicting 0.01 costs a great deal — the loss punishes confident mistakes far harder than it rewards confident hits, which is what keeps a model from bluffing.