In Keras documentation at this page, https://keras.io/layers/recurrent/, I wonder what's the difference between GRU and GRUCell, which one I should use if I'd like to create a GRU recurrent network. Similarly, I have confusion between LSTM and LSTMCell, and RNN and SimpleRNN.

Checking the source code: the class inheritance is like

Layer => RNN
Layer => GRUCell
Layer => LSTMCell

RNN => SimpleRNN


  • 1
    $\begingroup$ This question has been answered on SO. $\endgroup$ – today Jul 9 '18 at 23:51

In GRU/LSTM Cell, there is no option of return_sequences. That means it is just a cell of an unfolded GRU/LSTM unit.

The argument of GRU/LSTM i.e. return_sequences, if return_sequences=True, then returns all the output state of the GRU/LSTM.

GRU/LSTM Cell computes and returns only one timestamp.

But, GRU/LSTM can return sequences of all timestamps.

In Figure 1, the unit in loop is GRU/LSTM. In Figure 2, the cells shown are GRU/LSTM Cell which is an unfolded GRU/LSTM unit.

enter image description here

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.