Graph not resetting between backward passes?

You need to call state.detach_() . Otherwise, it will still hold on to the graph that created it, i.e. that of the first pass.

1 Like