NEW
Information-theoretic loss measuring divergence between true and predicted probability distributions for classification.
DESCRIPTION
Cross-entropy quantifies the inefficiency of assuming a predicted distribution when the true distribution generates outcomes. In machine learning, it is the standard loss for probabilistic classifiers, often with softmax or sigmoid outputs. Minimizing cross-entropy corresponds to maximizing likelihood under certain models. Variants include binary and categorical cross-entropy. It relates closely to KL divergence, differing by an additive entropy term.
ALTERNATIVE DEFINITIONS
Wikipedia
In information theory, the cross entropy between two probability distributions p and q over the same underlying set of events measures the average number of bits needed to identify an event drawn from the set, if a coding scheme is used that is optimized for an “incorrect” probability distribution q, rather than the “true” distribution p.
Links cross-entropy to coding inefficiency measured in bits.
scikit-learn
Log loss, aka logistic loss or cross-entropy loss, measures the performance of a classification model where the prediction input is a probability value between 0 and 1.
Practical framing for probabilistic classifiers and evaluation.
TensorFlow
Computes the crossentropy loss between the labels and predictions.
API-centric definition focused on labels and predictions.
RELATED TERMS
Entropy KL Divergence Log Loss Softmax Maximum Likelihood Perplexity Binary Cross-Entropy Categorical Cross-Entropy
COMPETING TERMS
RELATIONS
- Narrower: Binary Cross-Entropy
KNOWLEDGE AREAS
TARGET AUDIENCE
Data Scientist AI Engineer MLOps Engineer
EXTERNAL SOURCES
- Wikipedia - Cross-entropy
- Deep Learning (Goodfellow, Bengio, Courville) - Textbook section on likelihood and cross-entropy
- PyTorch - Loss function documentation and usage
- Google Developers - ML crash course on log loss
TOP QUESTIONS
Why is Cross-entropy preferred for classification?
It directly compares predicted probabilities with true labels, aligning with maximum likelihood and providing strong gradients for training.
Category: Relevancy
How does Cross-entropy relate to KL divergence?
Cross-entropy equals entropy plus KL divergence. Minimizing cross-entropy with fixed true distribution reduces KL divergence.
Category: Relationship
When should I use binary vs. categorical Cross-entropy?
Use binary for independent binary labels or two-class problems and categorical for mutually exclusive multi-class softmax outputs.
Category: Guidance
What is a common pitfall when computing Cross-entropy?
Passing unnormalized logits to a function expecting probabilities, or vice versa, causes incorrect loss values and unstable training.
Category: Mistakes
How does label smoothing affect Cross-entropy?
Label smoothing replaces hard targets with softened ones to reduce overconfidence, improving generalization in many cases.
Category: Technique
Does lower Cross-entropy always mean better calibration?
Not necessarily. A model can have low loss but still be miscalibrated; calibration metrics like ECE provide complementary insight.
Category: Misunderstanding
What numerical stability tricks are used with Cross-entropy?
Use log-sum-exp trick, fused log-softmax functions, and clipping probabilities to avoid log(0) and overflow.
Category: HowTo
How does class imbalance affect Cross-entropy?
It can bias training toward majority classes. Weighted loss or focal loss can mitigate this.
Category: Risk
Is Cross-entropy appropriate for regression?
No. Cross-entropy is for probabilistic classification; regression typically uses losses like MSE or MAE.
Category: Guidance