Skip to content
fn

bce_loss_op

→TensorImplPtr
int bce_loss_op(const int & input, const int & target, const int & weight, int reduction, double eps)

Public binary cross-entropy entry point.

Parameters

inputTensorImplPtr
Probabilities in (0,1)(0, 1).
targetTensorImplPtr
Binary targets in {0,1}\{0, 1\} of the same shape.
weightTensorImplPtr
Per-element weighting tensor; pass a ones tensor when unused.
reductionint
0 (None), 1 (Mean), or 2 (Sum).
epsdouble
Clamp inside the logarithm to keep gradients finite.

Returns

TensorImplPtr

Reduced or per-element loss tensor.