-
Notifications
You must be signed in to change notification settings - Fork 26.3k
add retain_grad method, to variable, so gradient gets stored during…
#2078
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
Conversation
|
@apaszke is likely going to reject this PR :) |
… backpop, on non-user variables
|
(added unit test) |
|
(ah, our comments crossed en-route, or rather, I just wrote and pasted without noticing there were new comments :-) ) |
|
alright, fair enough. Can we keep this open until someone implement/proposes a better solution (no need to merge, but at least its a place-holder to remind us to find a better way to do something similar?) |
|
(or ... could we merge for now, and then replace the user API method, ie |
|
I'll chat with @apaszke today and discuss, we'll keep this open for now. |
|
@apaszke 's main reservations with this PR is that the PR in it's current state creates a reference cycle (which means higher memory usage until the GC kicks in). instead of holding onto self, you can create a weakref on self instead. |
|
Also, the method can insert the same hook multiple times, which is unnecessary |
|
closing in favor of #2199 |
|
Awesome, thanks! :-) |
…ddppq (pytorch#2078) * Fix cmake dependency error in static library case. Peer coded with @bddppq * Temporarily add back the private dependencies to the binary targets
… backpop, on non-user variables
Simplifies solving issues such as https://discuss.pytorch.org/t/problem-about-tensor-and-variable/4719