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
SimpleCompositeLoss
is an implementation of the Loss
abstract class that can
combine different Loss
functions 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
ConstructorsConstructorDescriptionCreates a new empty instance ofCompositeLoss
that can combine the givenLoss
components.SimpleCompositeLoss
(String name) Creates a new empty instance ofCompositeLoss
that can combine the givenLoss
components. -
Method Summary
Modifier and TypeMethodDescriptionAdds a Loss that applies to all labels and predictions to this composite loss.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, updateAccumulators
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, updateAccumulator
Methods inherited from class ai.djl.training.evaluator.Evaluator
checkLabelShapes, checkLabelShapes, getName
-
Constructor Details
-
Method Details
-
addLoss
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:
inputForComponent
in 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
-