BinaryCrossEntropyLoss

class BinaryCrossEntropyLoss @JvmOverloads constructor(epsilon: Float = 1.0E-7f) : Loss(source)

Binary Cross-Entropy Loss.

BCE(pred, target) = -target * log(pred) + (1 - target) * log(1 - pred)

This loss is used for binary classification where predictions are probabilities in the range 0, 1.

For numerical stability, predictions are clamped to epsilon, 1 - epsilon.

Parameters

epsilon

Small value for numerical stability. Default is 1e-7.

Constructors

Link copied to clipboard
constructor(epsilon: Float = 1.0E-7f)

Functions

Link copied to clipboard
open override fun <T : DType, V> forward(preds: Tensor<T, V>, targets: Tensor<out DType, *>, ctx: ExecutionContext, reduction: Reduction): Tensor<T, V>