public class TopKAccuracy extends Accuracy
TopKAccuracy is a TrainingMetric that computes the accuracy of the top k
predictions.
TopKAccuracy differs from Accuracy 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.
| Constructor and Description |
|---|
TopKAccuracy(int topK)
Creates an instance of
TopKAccuracy metric that computes topK accuracy across axis 1
along the 0th index. |
TopKAccuracy(int index,
int topK)
Creates an instance of
TopKAccuracy metric that computes topK accuracy across axis 1
along the given index. |
TopKAccuracy(java.lang.String name,
int index,
int topK)
Creates a
TopKAccuracy instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
update(NDArray labels,
NDArray predictions)
Computes and updates the accuracy based on the labels and predictions.
|
addCorrectInstances, addTotalInstances, getValue, reset, updatecheckLabelShapes, checkLabelShapes, duplicate, getNamepublic TopKAccuracy(java.lang.String name,
int index,
int topK)
TopKAccuracy instance.name - the accuracy name, default "Top_K_Accuracy"index - the index of the NDArray in labels to compute topK accuracy fortopK - the value of Kpublic TopKAccuracy(int index,
int topK)
TopKAccuracy metric that computes topK accuracy across axis 1
along the given index.index - the index of the NDArray in labels to compute topK accuracy fortopK - the value of Kpublic TopKAccuracy(int topK)
TopKAccuracy metric that computes topK accuracy across axis 1
along the 0th index.topK - the value of K