Class SigmoidBinaryCrossEntropyLoss

java.lang.Object
ai.djl.training.evaluator.Evaluator
ai.djl.training.loss.Loss
ai.djl.training.loss.SigmoidBinaryCrossEntropyLoss

public class SigmoidBinaryCrossEntropyLoss extends Loss
SigmoidBinaryCrossEntropyLoss is a type of Loss.

Sigmoid binary cross-entropy loss is defined by: \(L = -\sum_i {label_i * log(prob_i) * posWeight + (1 - label_i) * log(1 - prob_i)}\) where \(prob = \frac{1}{1 + e^{-pred}}\)

  • Constructor Details

    • SigmoidBinaryCrossEntropyLoss

      public SigmoidBinaryCrossEntropyLoss()
      Performs Sigmoid cross-entropy loss for binary classification.
    • SigmoidBinaryCrossEntropyLoss

      public SigmoidBinaryCrossEntropyLoss(String name)
      Performs Sigmoid cross-entropy loss for binary classification.
      Parameters:
      name - the name of the loss
    • SigmoidBinaryCrossEntropyLoss

      public SigmoidBinaryCrossEntropyLoss(String name, float weight, boolean fromSigmoid)
      Performs Sigmoid cross-entropy loss for binary classification.
      Parameters:
      name - the name of the loss
      weight - the weight to apply on the loss value, default 1
      fromSigmoid - whether the input is from the output of sigmoid, default false
  • Method Details

    • evaluate

      public NDArray evaluate(NDList label, NDList prediction)
      Calculates the evaluation between the labels and the predictions.
      Specified by:
      evaluate in class Evaluator
      Parameters:
      label - the correct values
      prediction - the predicted values
      Returns:
      the evaluation result