Skip to main content

ClikaRT::ops::binary_cross_entropy_with_logits

function

binary_cross_entropy_with_logits()

Tensor binary_cross_entropy_with_logits(
    Tensor input,
    Tensor target,
    OptionalTensor weight = {},
    Reduction reduction = Reduction::Mean,
    OptionalTensor pos_weight = {}
)

Binary cross-entropy on RAW LOGITS (sigmoid fused, numerically stable).

Computes binary_cross_entropy(sigmoid(input), target) in one pass without materializing the probabilities. pos_weight scales the positive-class term per element (class-imbalance correction).

Parameters

  • input: raw logits.
  • target: targets in [0, 1]; same shape as input.
  • weight: optional per-element weight; broadcastable.
  • reduction: None / Mean / Sum; default Mean.
  • pos_weight: optional positive-class weight; broadcastable.

Returns: the loss (0-D under Mean/Sum).

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) on a shape mismatch.

Declared in ClikaRT/compute/ops.h, line 2918