Package ai.djl.training.loss
Class SimpleCompositeLoss
- java.lang.Object
-
- ai.djl.training.evaluator.Evaluator
-
- ai.djl.training.loss.Loss
-
- ai.djl.training.loss.AbstractCompositeLoss
-
- ai.djl.training.loss.SimpleCompositeLoss
-
public class SimpleCompositeLoss extends AbstractCompositeLoss
SimpleCompositeLossis an implementation of theLossabstract class that can combine differentLossfunctions by adding the individual losses together.For cases where the losses use only a single index of the labels and/or predictions, use the
IndexLoss.For an example of using this loss, see the captcha training example.
-
-
Field Summary
-
Fields inherited from class ai.djl.training.loss.AbstractCompositeLoss
components
-
Fields inherited from class ai.djl.training.evaluator.Evaluator
totalInstances
-
-
Constructor Summary
Constructors Constructor Description SimpleCompositeLoss()Creates a new empty instance ofCompositeLossthat can combine the givenLosscomponents.SimpleCompositeLoss(java.lang.String name)Creates a new empty instance ofCompositeLossthat can combine the givenLosscomponents.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleCompositeLossaddLoss(Loss loss)Adds a Loss that applies to all labels and predictions to this composite loss.protected ai.djl.util.Pair<NDList,NDList>inputForComponent(int componentIndex, NDList labels, NDList predictions)Returns the inputs to computing the loss for a component loss.-
Methods inherited from class ai.djl.training.loss.AbstractCompositeLoss
addAccumulator, evaluate, getAccumulator, getComponents, resetAccumulator, updateAccumulator
-
Methods inherited from class ai.djl.training.loss.Loss
elasticNetWeightedDecay, elasticNetWeightedDecay, elasticNetWeightedDecay, elasticNetWeightedDecay, hingeLoss, hingeLoss, hingeLoss, l1Loss, l1Loss, l1Loss, l1WeightedDecay, l1WeightedDecay, l1WeightedDecay, l2Loss, l2Loss, l2Loss, l2WeightedDecay, l2WeightedDecay, l2WeightedDecay, maskedSoftmaxCrossEntropyLoss, maskedSoftmaxCrossEntropyLoss, maskedSoftmaxCrossEntropyLoss, quantileL1Loss, quantileL1Loss, sigmoidBinaryCrossEntropyLoss, sigmoidBinaryCrossEntropyLoss, sigmoidBinaryCrossEntropyLoss, softmaxCrossEntropyLoss, softmaxCrossEntropyLoss, softmaxCrossEntropyLoss
-
Methods inherited from class ai.djl.training.evaluator.Evaluator
checkLabelShapes, checkLabelShapes, getName
-
-
-
-
Constructor Detail
-
SimpleCompositeLoss
public SimpleCompositeLoss()
Creates a new empty instance ofCompositeLossthat can combine the givenLosscomponents.
-
SimpleCompositeLoss
public SimpleCompositeLoss(java.lang.String name)
Creates a new empty instance ofCompositeLossthat can combine the givenLosscomponents.- Parameters:
name- the display name of the loss
-
-
Method Detail
-
addLoss
public SimpleCompositeLoss addLoss(Loss loss)
Adds a Loss that applies to all labels and predictions to this composite loss.- Parameters:
loss- the loss to add- Returns:
- this composite loss
-
inputForComponent
protected ai.djl.util.Pair<NDList,NDList> inputForComponent(int componentIndex, NDList labels, NDList predictions)
Returns the inputs to computing the loss for a component loss.- Specified by:
inputForComponentin classAbstractCompositeLoss- Parameters:
componentIndex- the index of the component losslabels- the label input to the composite losspredictions- the predictions input to the composite loss- Returns:
- a pair of the (labels, predictions) inputs to the component loss
-
-