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

why setting retain_graph=True #8

Open
BaohaoLiao opened this issue Apr 18, 2023 · 0 comments
Open

why setting retain_graph=True #8

BaohaoLiao opened this issue Apr 18, 2023 · 0 comments

Comments

@BaohaoLiao
Copy link

BaohaoLiao commented Apr 18, 2023

When you do .backward(), you set retain_graph=True as follows:

minREV/rev.py

Line 252 in 4f32aca

g_Y_1.backward(dY_2, retain_graph=True)

minREV/rev.py

Line 283 in 4f32aca

f_X_2.backward(dY_1, retain_graph=True)

According to this discussion, retain_graph=True will make a backward pass that does not delete intermediary results. The above two backward passes don't share the same sub-network. I think deleting intermediate results will not affect them. And setting retain_graph=False will further save more memory.

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