MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / topk_errors

Function topk_errors

slowfast/utils/metrics.py:43–52  ·  view source on GitHub ↗

Computes the top-k error for each k. Args: preds (array): array of predictions. Dimension is N. labels (array): array of labels. Dimension is N. ks (list): list of ks to calculate the top accuracies.

(preds, labels, ks)

Source from the content-addressed store, hash-verified

41
42
43def topk_errors(preds, labels, ks):
44 """
45 Computes the top-k error for each k.
46 Args:
47 preds (array): array of predictions. Dimension is N.
48 labels (array): array of labels. Dimension is N.
49 ks (list): list of ks to calculate the top accuracies.
50 """
51 num_topks_correct = topks_correct(preds, labels, ks)
52 return [(1.0 - x / preds.size(0)) * 100.0 for x in num_topks_correct]
53
54
55def topk_accuracies(preds, labels, ks):

Callers

nothing calls this directly

Calls 1

topks_correctFunction · 0.85

Tested by

no test coverage detected