Isabella_Costa_Maia:

Just to confirm, you’re saying that I should detach the hidden state in the input of the lstm layer from the decoder class, right?


Yes, assuming you want to use the previous “values” of the hidden state, but do not want to extend the computation graph.



 Isabella_Costa_Maia:

And what is the proper way of detaching the hidden state if it is a tuple? I’ve tried to do it as you suggested but I’m getting the following:


You can recreate the tuple via:
hidden = tuple(h.detach() for h in hidden)