Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one of the variables needed for gradient computation has been modified by an inplace operation #72

Open
miaoshuyu opened this issue Dec 19, 2018 · 2 comments

Comments

@miaoshuyu
Copy link

Traceback (most recent call last):
File "train_test.py", line 454, in
train()
File "train_test.py", line 327, in train
loss.backward()
File "/home/miao/anaconda3/lib/python3.6/site-packages/torch/tensor.py", line 93, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/home/miao/anaconda3/lib/python3.6/site-packages/torch/autograd/init.py", line 90, in backward
allow_unreachable=True) # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation

when i run python train_test.py, i met this problem.How can i solve it.

@miaoshuyu
Copy link
Author

miaoshuyu commented Dec 23, 2018

The problem has been solved:
in layers/modules/l2norm.py
x /= norm
to:
x = x / norm

@DonghoonPark12
Copy link

x = torch.div(x,norm) is also okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants