Correct way to do backpropagation through time?

Shouldn’t the truncated example be

# truncated to the last K timesteps
for t in range(T):
    out = model(out)
    if T - t == K:
        out.backward()
        out.detach()
out.backward()
4 Likes