Binary Cross-Entropy Calculator

Measure single, batch, weighted, and multi-label binary cross-entropy, inspect gradients, compare probabilities, visualize sample losses, and export complete machine learning results instantly with confidence.

Calculator inputs

Single prediction

Batch prediction data

Use commas, spaces, tabs, semicolons, or new lines.
Leave empty to use weight 1 for every sample.
Columns: label, prediction, optional sample weight.

Multi-label matrices

Enter one sample per line. Separate class values with commas, spaces, tabs, or semicolons.

Values follow the selected probability or logit mode.
Leave empty to assign weight 1 to every label.

Weighting and numerical settings

Formula used

BCE = -[y × ln(p) + (1 - y) × ln(1 - p)]
Weighted BCE = sample_weight × class_weight × BCE
Stable logit form = max(z, 0) - z × y + ln(1 + exp(-|z|))

How to use this calculator

  1. Select single, batch, or multi-label calculation mode.
  2. Choose probabilities or logits as the prediction input.
  3. Enter labels, predictions, and optional sample weights.
  4. Adjust class weights, clipping, threshold, and reduction.
  5. Submit the form to inspect losses and gradients.
  6. Review charts, classification metrics, and row-level details.
  7. Copy, print, or export the completed calculation.

Example data

Actual labelPredicted probabilityInterpretationApproximate BCE
10.95Confident and correct0.0513
10.50Uncertain prediction0.6931
10.05Confident and incorrect2.9957
00.05Confident and correct0.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.

Related Calculators

Confusion Matrix CalculatorClassification Accuracy CalculatorRecall CalculatorSpecificity CalculatorSensitivity CalculatorFalse Positive Rate CalculatorFalse Negative Rate CalculatorMatthews Correlation Coefficient CalculatorBalanced Accuracy CalculatorLog Loss Calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.