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

Questions about in-place operations #13

Open
misaka0502 opened this issue May 26, 2024 · 0 comments
Open

Questions about in-place operations #13

misaka0502 opened this issue May 26, 2024 · 0 comments

Comments

@misaka0502
Copy link

When I ran train_expert.py, I got this error:
RuntimeError: Output 1 of SplitBackward0 is a view and is being modified inplace. This view is the output of a function that returns multiple views. Such functions do not allow the output views to be modified inplace. You should replace the inplace operation by an out-of-place one.,this happened in:

return reparameterize(means, log_stds.clamp_(-20, 2))

After I looked up the relevant information, I found that the error occurred in log_stds.clamp_(-20, 2). According to the information I found, clamp_() is an in-place operation because it is appended with the suffix _. It attempts to modify log_stds, but log_stds is obtained by means, log_stds = self.net(states).chunk(2, dim=-1), which violates PyTorch's rules. When I change clamp_ to clamp, the program can run normally. So why did you originally use clamp_ instead of clamp? What are the considerations here?

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

1 participant