Skip to content
ENExplore Calculators

Binary Cross Entropy Calculator

Calculate the binary cross-entropy loss for binary classification predictions.

About Binary Cross Entropy Calculator

Binary cross-entropy measures how far a predicted probability is from the true binary label: BCE = −(y·ln(p) + (1−y)·ln(1−p)). When y = 1, only the first term is active and loss grows as p moves away from 1; when y = 0, only the second term is active and loss grows as p moves away from 0. This is the standard loss function for binary classifiers with a sigmoid output, and it penalizes confident wrong predictions far more heavily than a squared-error loss would, since ln(p) → −∞ as p → 0.

Formula

BCE = -(y × ln(p) + (1 - y) × ln(1 - p))

y
True binary label (0 or 1)
p
Predicted probability that y = 1

Worked example

With the default values below, Binary Cross Entropy Calculator returns Binary Cross-Entropy Loss of 0.223144. Change any input above and every figure here is recalculated in your browser.

Inputs used

True Label (y)one of 0 (negative class), 1 (positive class)
1 (positive class)
Predicted Probability (p)accepts 0–1
0.8

Results

Binary Cross-Entropy Loss
0.223144
Positive-Class Term
-0.223144
Negative-Class Term
0.000000

Step by step

  1. 1Positive-class term: y × ln(p)= -0.223144
  2. 2Negative-class term: (1 − y) × ln(1 − p)= 0.000000
  3. 3BCE: −(positive term + negative term)= 0.223144

Assumptions and limits

  • The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 6 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Why does BCE use natural log instead of log base 2?

Natural log (ln) is the conventional choice in most deep learning frameworks because it simplifies the gradient during backpropagation through the sigmoid function; log base 2 would just scale the loss by a constant factor (1/ln(2)) without changing which model is 'better.'

What happens if p is exactly 0 or 1 and the prediction is wrong?

The loss becomes infinite in theory (ln(0) is undefined/−∞), which is why in practice predicted probabilities are clamped to a small epsilon away from exactly 0 or 1 before computing the loss, as this calculator does internally.

How is BCE related to log loss?

They are the same formula — 'log loss' is simply the more general/statistical name for binary cross-entropy loss applied to a single sample; averaging BCE over many samples gives the dataset-level log loss reported by tools like scikit-learn.

Binary Cross Entropy Calculator | Calcrivo