Closed giuliolovisotto closed 3 years ago
Thanks for making an issue! Does this still happen with the latest version of the library? We became aware of this issue (it actually only happens with PyTorch 1.7) a few months ago and so we changed that line to use .reshape() instead:
The updated version should be available on PyPI; let us know if the problem persists after a pip install --upgrade robustness
!
Great thanks, updating to the newest version fixed it! Don't know if you want to change the robustness version in the requirements.txt file for the other project.
Hi, I found a problem reproducing the basic example in https://github.com/microsoft/robust-models-transfer (I downloaded
resnet18_l2_eps3.ckpt
).Problem is that I get NaN values for accuracy. If I print the exception caught at Line 470 of
robustness/train.py
it says the followingUserWarning: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
I investigated a bit and I can fix this by adding
.contiguous()
in the accuracy computation inrobustness/tools/helpers.py
:correct_k = correct[:k].contiguous().view(-1).float()
, I found a similar issue here https://github.com/cezannec/capsule_net_pytorch/issues/4. The problem was when computing top-5 accuracy specifically (I assume it would happen with everything higher than top-1). Changing that line made everything work again.I haven't opened a pull request because I'm not sure why this happens in my setup, I am running everything inside this docker container and on an Nvidia Titan RTX.