Class MaskedSoftmaxCrossEntropyLoss

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

public class MaskedSoftmaxCrossEntropyLoss extends Loss
MaskedSoftmaxCrossEntropyLoss is an implementation of Loss that only considers a specific number of values for the loss computations, and masks the rest according to the given sequence.
  • Constructor Details

    • MaskedSoftmaxCrossEntropyLoss

      public MaskedSoftmaxCrossEntropyLoss()
      Creates a new instance of SoftmaxCrossEntropyLoss with default parameters.
    • MaskedSoftmaxCrossEntropyLoss

      public MaskedSoftmaxCrossEntropyLoss(String name)
      Creates a new instance of SoftmaxCrossEntropyLoss with default parameters.
      Parameters:
      name - the name of the loss
    • MaskedSoftmaxCrossEntropyLoss

      public MaskedSoftmaxCrossEntropyLoss(String name, float weight, int classAxis, boolean sparseLabel, boolean fromLogit)
      Creates a new instance of MaskedSoftmaxCrossEntropyLoss with the given parameters.
      Parameters:
      name - the name of the loss
      weight - the weight to apply on the loss value, default 1
      classAxis - the axis that represents the class probabilities, default -1
      sparseLabel - whether labels are 1-D integer array of [batch_size] (false) or 2-D probabilities of [batch_size, n-class] (true), default true
      fromLogit - if true, the inputs are assumed to be the numbers before being applied with softmax. Then logSoftmax will be applied to input, default false
  • Method Details

    • evaluate

      public NDArray evaluate(NDList labels, NDList predictions)
      Calculates the evaluation between the labels and the predictions. The label parameter is an NDList that contains the label and the mask sequence in that order.
      Specified by:
      evaluate in class Evaluator
      Parameters:
      labels - the NDList that contains correct values and the mask sequence
      predictions - the predicted values
      Returns:
      the evaluation result