# Why use two LSTM layers one after another?

In the example on the Keras site, seq2seq_translate.py on line 189, there is a LSTM layer after another (the first with return_sequences=True), but another example lstm_seq2seq.py which does the same thing but letter-by-letter uses only one LSTM in the encoder. My code looks like:

encoder = LSTM(latent_dim, return_sequences=True)(encoder_inputs)
encoder_outputs, state_h, state_c = LSTM(latent_dim, return_state=True)(encoder)


My question is why does the word-by-word version use two LSTM layers? And why is the return_sequences used?

• Thanks @pythinker - I added some code to my question - so I've got the return_sequences and return_state around the right way? – Nic Cottrell Aug 12 '18 at 20:18
• return_state=False by default though, so isn't it required for state_h, state_c to be returned? – Nic Cottrell Aug 13 '18 at 7:25