bce_loss

Function bce_loss 

Source
pub fn bce_loss<B>(
    prediction: &Tensor<B>,
    target: &Tensor<B>,
) -> Result<Tensor<B>, Error>
where B: Backend,
Expand description

Binary Cross-Entropy loss for probabilities in [0, 1].

Computes: -mean(target * log(pred) + (1 - target) * log(1 - pred))

§Arguments

  • prediction: predicted probabilities in (0, 1) — typically sigmoid output
  • target: binary targets in {0, 1}

§Warning

Numerically unstable if prediction values are exactly 0 or 1. Use bce_with_logits_loss for better stability.