Cross-Entropy Loss
Cross-entropy loss trains a probabilistic classifier by penalizing low probability assigned to the target class or target distribution.
For a target distribution and predicted probabilities :
For a one-hot target with true class :
With logits :
Binary Cross-Entropy
For binary classification with probability :
Multi-label classification usually applies binary cross-entropy independently to each label, not softmax cross-entropy across mutually exclusive classes.
Target Types
| Target Type | Loss Form | Main Check |
|---|---|---|
| one-hot class | classes must be mutually exclusive | |
| soft label | target distribution should sum to one | |
| binary label | BCE | threshold and prevalence affect reported metrics |
| multi-label | independent BCE per label | labels are not mutually exclusive |
| label-smoothed class | cross-entropy with smoothed target | report smoothing value and calibration impact |
If labels are ordinal, censored, weak, or noisy, plain cross-entropy may be a convenient surrogate but not a complete statement of the label semantics.
Relation to Likelihood
Cross-entropy on one-hot labels is the same training signal as negative log-likelihood for categorical labels:
It can also be written as entropy plus KL divergence:
Since is fixed with respect to , minimizing cross-entropy minimizes the KL divergence from the target distribution to the model distribution.
Logits and Stability
Cross-entropy is usually computed from logits directly:
Stable implementations use a log-sum-exp trick:
This avoids overflow and avoids applying softmax twice.
Metric Boundary
Cross-entropy trains probabilities, while many reported metrics use hard decisions or rankings:
| Reported Metric | Extra Decision |
|---|---|
| accuracy | argmax decision rule |
| F1 | threshold and averaging rule |
| AUROC | ranking of scores |
| AUPRC | ranking under class imbalance |
| calibration | probability reliability, not only correctness |
For imbalanced bioactivity, toxicity, retrieval, or screening tasks, a lower cross-entropy can coexist with weak top-k enrichment or poor calibration.
Checks
- Are labels mutually exclusive, multi-label, soft labels, or ordinal labels?
- Are logits passed to a numerically stable implementation, rather than softmaxed twice?
- Is class imbalance handled by weighting, sampling, or threshold tuning?
- Is the reported metric accuracy, F1, AUROC, AUPRC, calibration, or NLL?
- Is label smoothing used, and is it reported?