accuracy
anomaly_match.utils.accuracy
¶
Accuracy and balanced accuracy metrics.
accuracy(output, target, topk=(1,))
¶
Computes the accuracy over the k top predictions for the specified values of k.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
Tensor
|
Model output logits or probabilities with shape [batch_size, num_classes] |
required |
target
|
Tensor
|
Ground truth labels with shape [batch_size] or [batch_size, 1] |
required |
topk
|
tuple[int, ...]
|
Tuple specifying which top-k accuracies to compute (e.g., (1,) or (1, 5)) |
(1,)
|
Returns:
| Type | Description |
|---|---|
list[Tensor]
|
List of tensors, each containing the top-k accuracy value (in percentage) |
list[Tensor]
|
for the specified k values |
Note
This implementation is based on the PyTorch ImageNet example