Commit b31fa412 authored by sunxx1's avatar sunxx1
Browse files

Merge branch 'fix_main_acc' into 'main'

修复分类网络训练时tensor不连续报错

See merge request dcutoolkit/deeplearing/dlexamples_new!15
parents 421d6843 e56b9b9e
......@@ -501,7 +501,7 @@ def accuracy(output, target, topk=(1,)):
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, keepdim=True)
correct_k = correct[:k].contiguous().view(-1).float().sum(0, keepdim=True)
res.append(correct_k.mul_(100.0 / batch_size))
return res
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment