Interface Loss

All Superinterfaces:
BiFunction<Tensor,Tensor,Tensor>

public interface Loss extends BiFunction<Tensor,Tensor,Tensor>
Loss functions.
  • Method Details

    • l1

      static Loss l1()
      Mean Absolute Error (L1) Loss Function.
      Returns:
      the loss functor.
    • mse

      static Loss mse()
      Mean Squared Error (L2) Loss Function.
      Returns:
      the loss functor.
    • nll

      static Loss nll()
      Negative Log-Likelihood Loss Function.
      Returns:
      the loss functor.
    • crossEntropy

      static Loss crossEntropy()
      Cross Entropy Loss Function.
      Returns:
      the loss functor.
    • hingeEmbedding

      static Loss hingeEmbedding()
      Hinge Embedding Loss Function.
      Returns:
      the loss functor.
    • bce

      static Loss bce()
      Binary Cross-Entropy Loss Function. Measures the binary cross-entropy between the target and the input probabilities. Input should be in [0,1].
      Returns:
      the loss functor.
    • bceWithLogits

      static Loss bceWithLogits()
      Binary Cross-Entropy with Logits Loss Function. Combines a sigmoid activation and binary cross-entropy in a numerically stable way.
      Returns:
      the loss functor.
    • smoothL1

      static Loss smoothL1()
      Smooth L1 (Huber) Loss Function. Uses a squared term if the absolute element-wise error falls below beta (default 1) and an L1 term otherwise. This is less sensitive to outliers than MSE and avoids the gradient discontinuity of plain MAE.
      Returns:
      the loss functor.
    • huber

      static Loss huber(double delta)
      Huber Loss Function. Equivalent to smooth L1 when delta = 1.
      Parameters:
      delta - the threshold at which to change between L1 and L2.
      Returns:
      the loss functor.
    • kl

      static Loss kl()
      Kullback-Leibler Divergence Loss Function.
      Returns:
      the loss functor.
    • marginRanking

      static Tensor marginRanking(Tensor input1, Tensor input2, Tensor target)
      Margin Ranking Loss Function.
      Parameters:
      input1 - the first input.
      input2 - the second input.
      target - the target/truth.
      Returns:
      the loss.
    • tripleMarginRanking

      static Tensor tripleMarginRanking(Tensor anchor, Tensor positive, Tensor negative)
      Triplet Margin Ranking Loss Function.
      Parameters:
      anchor - the first input.
      positive - the second input.
      negative - the third input.
      Returns:
      the loss.