pytorch/examples

Doc comment on `accuracy` method in imagenet example, incorrect?

Open

#312 geöffnet am 27. Feb. 2018

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Python (9.429 Forks)batch import
good first issue

Repository-Metriken

Stars
 (21.634 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

I'm confused with the doc comment for the accuracy function in the imagenet example:

def accuracy(output, target, topk=(1,)):
    """Computes the precision@k for the specified values of k"""
    maxk = max(topk)
    batch_size = target.size(0)

    _, pred = output.topk(maxk, 1, True, True)
    pred = pred.t()
    correct = pred.eq(target.view(1, -1).expand_as(pred))

    res = []
    for k in topk:
        correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
        res.append(correct_k.mul_(100.0 / batch_size))
return res

https://github.com/pytorch/examples/blob/master/imagenet/main.py#L298-L299

This seems like it computes accuracy and not precision as false positives are not accounted for. Should the doc comment read "Computes the accuracy@k for the specified values of k" or is my understanding of precision for object detection incorrect?

Many thanks for pytorch, it's a great library!

Contributor Guide