`MaskedSelect can't differentiate the mask` with torch 0.3.0 and 0.3.1
vtjeng opened this issue · 2 comments
vtjeng commented
I tried running examples/mnist.py
unmodified, and ran into the following error.
Traceback (most recent call last):
File ".../convex_adversarial/examples/mnist.py", line 96, in <module>
train_robust(train_loader, model, opt, args.epsilon, t, train_log)
File ".../convex_adversarial/examples/mnist.py", line 27, in train_robust
Variable(X), Variable(y))
File ".../convex_adversarial/convex_adversarial/dual.py", line 169, in robust_loss
dual = DualNetBounds(net, X[i], epsilon)
File ".../convex_adversarial/convex_adversarial/dual.py", line 85, in __init__
subset_eye.scatter_(1, self.I[-1].data.nonzero(), d[self.I[-1]].data[:,None])
File "/usr/local/lib/python3.5/dist-packages/torch/autograd/variable.py", line 74, in __getitem__
return MaskedSelect.apply(self, key)
File "/usr/local/lib/python3.5/dist-packages/torch/autograd/_functions/tensor.py", line 462, in forward
assert not ctx.needs_input_grad[1], "MaskedSelect can't differentiate the mask"
AssertionError: MaskedSelect can't differentiate the mask
I ran into a similar error running examples/2D.ipynb
.
This error does not have to do with the convex_adversarial
package, but with torch-0.3.0.post4
and torch-0.3.1
(a quick search of the AssertionError
shows many users facing similar issues). Rolling back to torch-0.2.0.post2
solved the problem for me (see previous versions).
riceric22 commented
Thanks for opening an issue! I am aware of this problem, and I have a newer version that I'll be releasing pretty soon that works with the latest versions of PyTorch. If you can't wait and want to use the latest version of PyTorch, a simple fix is to add .detach() to all the indexing variables.