Formula used
BCE = -[y × ln(p) + (1 - y) × ln(1 - p)]Weighted BCE = sample_weight × class_weight × BCEStable logit form = max(z, 0) - z × y + ln(1 + exp(-|z|))How to use this calculator
- Select single, batch, or multi-label calculation mode.
- Choose probabilities or logits as the prediction input.
- Enter labels, predictions, and optional sample weights.
- Adjust class weights, clipping, threshold, and reduction.
- Submit the form to inspect losses and gradients.
- Review charts, classification metrics, and row-level details.
- Copy, print, or export the completed calculation.
Example data
| Actual label | Predicted probability | Interpretation | Approximate BCE |
|---|---|---|---|
| 1 | 0.95 | Confident and correct | 0.0513 |
| 1 | 0.50 | Uncertain prediction | 0.6931 |
| 1 | 0.05 | Confident and incorrect | 2.9957 |
| 0 | 0.05 | Confident and correct | 0.0513 |
Interpretation guide
A loss near zero indicates a confident correct prediction. A larger loss indicates uncertainty or a confident mistake. Compare models only on equivalent datasets and reductions.
Binary cross-entropy evaluates probability quality, not only class decisions. Accuracy can remain unchanged while BCE improves. Better calibrated probabilities usually reduce average BCE.
Class weights help when positive and negative labels are imbalanced. Sample weights emphasize specific observations. Review both weighted and unweighted results before choosing a model.
Frequently asked questions
What does binary cross-entropy measure?
It measures the disagreement between binary labels and predicted probabilities.
Is a lower BCE always better?
A lower value is better when datasets, weights, and reductions match.
Why are probabilities clipped?
Clipping prevents undefined logarithms at exact probabilities zero and one.
Can I enter logits directly?
Yes. The calculator converts logits to probabilities using sigmoid.
What is weighted BCE?
Weighted BCE changes each observation’s influence before losses are aggregated.
How does BCE differ from accuracy?
Accuracy uses hard classes, while BCE evaluates probability confidence.
When should multi-label mode be used?
Use it when every sample may independently contain several labels.
Why can confident mistakes dominate loss?
Logarithmic penalties grow sharply when confidence supports the wrong label.
When should categorical cross-entropy be used instead?
Use it for mutually exclusive classes represented by one distribution.