LSTM and LSTMCell ?

I want to know the difference between the LSTM and LSTMCell in the pytorch document?And how to use it correctly.

3 Likes

LSTMCell takes ONE input x_t. You need to make a loop in order to do one pass of backprop through time.

LSTM takes a SEQUENCE of inputs x_1,x_2,…,x_T. No need to write a loop to do one pass of backprop through time.

15 Likes

ok, Thanks for your answer, Is there any other difference?

@tlaurent ok, Thanks for your answer, Is there any other difference?

I would guess that using LSTM() is faster than writing your own loop with LSTMCell (because it is optimized by cudnn).

6 Likes

@tlaurent ok thanks gor your answer, I will try it.

LSTMCell() is the building block of the LSTM(). In LSTM(), there are multiple LSTMCell() in one layer as equal as sequence length or unrolling length of network.

2 Likes

I made this example, I hope it helps RNNs/LSTMCellvsLSTM.ipynb at main · CarlosJose126/RNNs · GitHub

1 Like