Skip to content

Commit

Permalink
check if output is list
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiyangZhou committed Feb 1, 2019
1 parent 564f5a2 commit 800df43
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions torchreid/utils/torchtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)

if isinstance(output, (tuple, list)):
output = output[0]

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

0 comments on commit 800df43

Please sign in to comment.