torch 2.0.1, met some problem in function `accuracy()` and solved
wplf opened this issue · comments
line 18
the function view() has some problem when calculating topk=5
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces).
the instruction may solve this problem
correct_k = correct[:k].view(-1).float().sum(0)
changed to correct_k = correct[:k].float().sum()
sorry, this issues is for mobilenetv2