# why should we transfer final state to initial state (BPTT) in LSTM?

I am learning LSTM implementation in torch from this code,it has these two lines of code:

-- transfer final state to initial state (BPTT)
initstate_c:copy(lstm_c[#lstm_c])
initstate_h:copy(lstm_h[#lstm_h])


I don't understand why we should put the last cell state and the last hidden state to the initial state? Could someone tell me why?

• Thanks, I finally understand. Also in the above code, it says dloss/dfinal_state is 0, do you know why this is true? Jul 12, 2016 at 7:12