A three-class classifier outputs the probability vector , and the true class is the second one. What is the cross-entropy loss?
Deep learning, Loss functions
Level L2 Elementary. Length One-liner. Nature Mat Mathematical.
What's being asked
Whether you can apply the cross-entropy formula with a one-hot target.
Key idea
The target is one-hot: 1 for the true class and 0 elsewhere. So only the true class survives in the sum: nats (units of natural log).
Steps
- Write the one-hot target, .
- Substitute: nats.
- If the course uses base 2, the answer is bits. State which log you use.
Common mistakes
- Adding and as well. With a one-hot target those terms are multiplied by 0.
- Using binary cross-entropy for each class, . This is a different loss, not the one used for multi-class softmax outputs.
- Using (which gives ) without saying so.
How long your answer should be
One line.
Last checked on 4 December 2026.
Read this
Previous in Deep learning: You plot training and validation loss against epochs. What do the curves look like for (a) underfitting, (b) overfitting and (c) a learning rate that is too high, and what would you do in each case?
Next in Deep learning: Let , where the inputs and the parameters are all scalars and is the natural log. What is the computational graph with intermediate nodes, and how do you use backpropagation on it to compute ?