Why is `retain_graph=True` needed in some case but not in other

Thanks for editing.
But, could you please post a minimal executable snippet that would reproduce the error that you are facing.

From just skimming through this (second Model’s) code, I cannot see why this error would occur.

Anyway, were you able to understand the concept that I explained in my previous reply regarding what’s under the hood?

2 Likes