(output, target, topk=(1,))
| 23 | |
| 24 | |
| 25 | def accuracy(output, target, topk=(1,)): |
| 26 | maxk = max(topk) |
| 27 | batch_size = target.size(0) |
| 28 | |
| 29 | _, pred = output.topk(maxk, 1, True, True) |
| 30 | pred = pred.t() |
| 31 | correct = pred.eq(target.view(1, -1).expand_as(pred)) |
| 32 | |
| 33 | res = [] |
| 34 | for k in topk: |
| 35 | correct_k = correct[:k].view(-1).float().sum(0) |
| 36 | res.append(correct_k.mul_(100.0/batch_size)) |
| 37 | return res |
| 38 | |
| 39 | |
| 40 | class Cutout(object): |
nothing calls this directly
no outgoing calls
no test coverage detected