dgs.models.metric.metric.compute_accuracy¶
- dgs.models.metric.metric.compute_accuracy(prediction: torch.Tensor, target: torch.Tensor, topk: list[int] | None = None) dict[int, float][source]¶
Compute the accuracies of a predictor over a tuple of
k-top predictions. Will use the k-biggest values in prediction.- Parameters:
prediction – prediction matrix with shape
[B x num_classes].target – ground truth labels with shape
[B].topk – A list containing the number of values to check for the top-k accuracies. Default [1].
- Returns:
The accuracies for each of the
k-top predictions.