Package ai.djl.training.evaluator
Class IndexEvaluator
- java.lang.Object
-
- ai.djl.training.evaluator.Evaluator
-
- ai.djl.training.evaluator.IndexEvaluator
-
public class IndexEvaluator extends Evaluator
-
-
Field Summary
-
Fields inherited from class ai.djl.training.evaluator.Evaluator
totalInstances
-
-
Constructor Summary
Constructors Constructor Description IndexEvaluator(Evaluator evaluator, int index)
Constructs anIndexEvaluator
with the same index for both predictions and labels.IndexEvaluator(Evaluator evaluator, java.lang.Integer predictionsIndex, java.lang.Integer labelsIndex)
Constructs anIndexEvaluator
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAccumulator(java.lang.String key)
Adds an accumulator for the results of the evaluation with the given key.NDArray
evaluate(NDList labels, NDList predictions)
Calculates the evaluation between the labels and the predictions.float
getAccumulator(java.lang.String key)
Returns the accumulated evaluator value.void
resetAccumulator(java.lang.String key)
Resets the evaluator value with the given key.void
updateAccumulator(java.lang.String key, NDList labels, NDList predictions)
Updates the evaluator with the given key based on aNDList
of labels and predictions.-
Methods inherited from class ai.djl.training.evaluator.Evaluator
checkLabelShapes, checkLabelShapes, getName
-
-
-
-
Constructor Detail
-
IndexEvaluator
public IndexEvaluator(Evaluator evaluator, int index)
Constructs anIndexEvaluator
with the same index for both predictions and labels.- Parameters:
evaluator
- the base evaluatorindex
- the index for both predictions and labels
-
IndexEvaluator
public IndexEvaluator(Evaluator evaluator, java.lang.Integer predictionsIndex, java.lang.Integer labelsIndex)
Constructs anIndexEvaluator
.- Parameters:
evaluator
- the base evaluatorpredictionsIndex
- the predictions indexlabelsIndex
- the labels index
-
-
Method Detail
-
evaluate
public NDArray evaluate(NDList labels, NDList predictions)
Calculates the evaluation between the labels and the predictions.
-
addAccumulator
public void addAccumulator(java.lang.String key)
Adds an accumulator for the results of the evaluation with the given key.- Specified by:
addAccumulator
in classEvaluator
- Parameters:
key
- the key for the new accumulator
-
updateAccumulator
public void updateAccumulator(java.lang.String key, NDList labels, NDList predictions)
Updates the evaluator with the given key based on aNDList
of labels and predictions.This is a synchronized operation. You should only call it at the end of a batch or epoch.
- Specified by:
updateAccumulator
in classEvaluator
- Parameters:
key
- the key of the accumulator to updatelabels
- aNDList
of labelspredictions
- aNDList
of predictions
-
resetAccumulator
public void resetAccumulator(java.lang.String key)
Resets the evaluator value with the given key.- Specified by:
resetAccumulator
in classEvaluator
- Parameters:
key
- the key of the accumulator to reset
-
getAccumulator
public float getAccumulator(java.lang.String key)
Returns the accumulated evaluator value.- Specified by:
getAccumulator
in classEvaluator
- Parameters:
key
- the key of the accumulator to get- Returns:
- the accumulated value
-
-