Package ai.djl.training.evaluator
Class TopKAccuracy
java.lang.Object
ai.djl.training.evaluator.Evaluator
ai.djl.training.evaluator.AbstractAccuracy
ai.djl.training.evaluator.TopKAccuracy
TopKAccuracy is an Evaluator that computes the accuracy of the top k predictions.
TopKAccuracy differs from AbstractAccuracy in that it considers the prediction
to be `True` as long as the ground truth label is in the top K predicated labels. If `top_k = 1`,
then TopKAccuracy is identical to Accuracy.
-
Field Summary
Fields inherited from class ai.djl.training.evaluator.AbstractAccuracy
axis, correctInstancesFields inherited from class ai.djl.training.evaluator.Evaluator
totalInstances -
Constructor Summary
ConstructorsConstructorDescriptionTopKAccuracy(int topK) Creates an instance ofTopKAccuracyevaluator that computes topK accuracy across axis 1 along the 0th index.TopKAccuracy(String name, int topK) Creates aTopKAccuracyinstance. -
Method Summary
Modifier and TypeMethodDescriptionaccuracyHelper(NDList labels, NDList predictions) A helper for classes extendingAbstractAccuracy.Methods inherited from class ai.djl.training.evaluator.AbstractAccuracy
addAccumulator, evaluate, getAccumulator, resetAccumulator, updateAccumulator, updateAccumulatorsMethods inherited from class ai.djl.training.evaluator.Evaluator
checkLabelShapes, checkLabelShapes, getName
-
Constructor Details
-
TopKAccuracy
Creates aTopKAccuracyinstance.- Parameters:
name- the accuracy name, default "Top_K_Accuracy"topK- the value of K
-
TopKAccuracy
public TopKAccuracy(int topK) Creates an instance ofTopKAccuracyevaluator that computes topK accuracy across axis 1 along the 0th index.- Parameters:
topK- the value of K
-
-
Method Details
-
accuracyHelper
A helper for classes extendingAbstractAccuracy.- Specified by:
accuracyHelperin classAbstractAccuracy- Parameters:
labels- the labels to get accuracy forpredictions- the predictions to get accuracy for- Returns:
- a pair(number of total values, ndarray int of correct values)
-