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)
| 41 | |
| 42 | |
| 43 | def 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 | |
| 55 | def topk_accuracies(preds, labels, ks): |
nothing calls this directly
no test coverage detected