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

Better way to set retain_graph #732

Closed
AntixK opened this issue Jan 23, 2020 · 1 comment · Fixed by #733
Closed

Better way to set retain_graph #732

AntixK opened this issue Jan 23, 2020 · 1 comment · Fixed by #733
Assignees
Labels
question Further information is requested

Comments

@AntixK
Copy link
Contributor

AntixK commented Jan 23, 2020

Is there a better way to set retain_graph, especially when using two optimizers?

I have read the issue #356 and the corresponding fix, to set it by overriding the backward function.
However, this becomes messy especially when more than 1 optimizers are used, as the function doesn't have the optimizer_idx as an argument.

There are workarounds like naming the optimizer object and using that to set/reset the retain graph, but passing optimizer_idx would be great.

This shouldn't be difficult as the opt_idx variable is available inside the loop in which the backward function is called

  • Version [0.6.0]
@AntixK AntixK added the question Further information is requested label Jan 23, 2020
@williamFalcon
Copy link
Contributor

good suggestion. a pr for this would be great!

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

Successfully merging a pull request may close this issue.

2 participants