Pytorch – RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed

The problem is from my training loop: it doesn’t detach or repackage the hidden state in between batches? If so, then loss.backward() is trying to back-propagate all the way through to the start of time, which works for the first batch but not for the second because the graph for the first batch has been … Read more