Function dfdx::tensor_ops::bce_with_logits
source · pub fn bce_with_logits<S: Shape, E: Dtype, D: BinaryKernel<BCEKernelOp, E>, LTape, RTape>(
logits: Tensor<S, E, D, LTape>,
probs: Tensor<S, E, D, RTape>
) -> Tensor<S, E, D, LTape>where
LTape: Tape<E, D> + Merge<RTape>,
RTape: Tape<E, D>,
Expand description
Binary Cross Entropy With Logits in numerically stable way.
Computes target_probs * log(sigmoid(logits)) + (1 - target_probs) * log(1 - sigmoid(logits))
as (1 - target_probs) * logits + log(1 + exp(-logits))
.
Inputs
logits
- unnormalized inputs. NOT output of sigmoidtarget_probs
- target values between 0 and 1.
Numerically Stable Derivation
See https://www.tensorflow.org/api_docs/python/tf/nn/sigmoid_cross_entropy_with_logits for more information on this.