Cross-Entropy
A loss function that measures the difference between two probability distributions: the one predicted by the model and the actual one.
Idea
If the model confidently assigns a probability close to 1 to the correct class, the loss is small. If it 'guesses' with a probability of 0.01 — the loss is huge. The stronger the model's mistake, the harsher the punishment.
Where It Is Used
- Language models — predicting the next token out of hundreds of thousands of options;
- Classification — spam/not spam, positive/negative;
- Training Softmax layers — the combination of 'Softmax + Cross-Entropy' is almost in every classifier.
Relation to Perplexity
The perplexity of a language model is calculated from the cross-entropy: the lower the cross-entropy, the lower the perplexity and the more 'confident' the model is in continuing the text.
Binary Cross-Entropy
For tasks with two classes, the binary version is used — also known as log loss. Example: determining whether an email is spam or not.