Solved by albanD in post #2 
              
              
                Hi, 
The problem is that prev_output is linked to the previous forward you did. And so if you call backward after the new forward, it will try to backward through the previous forward as well. Hence the error you see. 
You can use retain_graph=True when you call .backward() to avoid this issue but t…