nayeemrizve / ups

"In Defense of Pseudo-Labeling: An Uncertainty-Aware Pseudo-label Selection Framework for Semi-Supervised Learning" by Mamshad Nayeem Rizve, Kevin Duarte, Yogesh S Rawat, Mubarak Shah (ICLR 2021)
MIT License
229 stars 40 forks source link

Don't use view in accuracy calc #2

Closed njhurst closed 3 years ago

njhurst commented 3 years ago

training crashed in the accuracy test code at:

  File "/home/njh/torchtoys/ups/utils/misc.py", line 41, in accuracy
    correct_k = correct[:k].view(-1).float().sum(0)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

changing to reshape(-1) appears to have fixed it.

nayeemrizve commented 3 years ago

Thank you for your feedback. I believe we used an older version of torch (probably 1.3.x). Therefore, .view(.) worked fine and we didn't notice this bug before.

xiaoliwang-717 commented 3 years ago

hi~I find a conflict between the torch and torchvision versions. You sure it's right?

nayeemrizve commented 3 years ago

hi~I find a conflict between the torch and torchvision versions. You sure it's right?

I have updated the README and requirements file with the correct version.