What are the output shape of LSTM with Keras implementation when "return_sequences" equals to "True" or "False" ?


Assuming your output state size is h. You will generate nxh for n data points if return_sequences is false. On the other hand you would be having nxtxh dimensional array as output if return_sequences is set to true. Here t is the number of timestamps in each data point.

  • $\begingroup$ So choosing return_sequences = True/False doesn't change the 3D array output shape? $\endgroup$ – user145959 Mar 2 '19 at 11:08
  • $\begingroup$ It does. In false case you got last hidden state out. But in true case every internal hidden state gets released out. $\endgroup$ – Kiritee Gak Mar 2 '19 at 11:10
  • $\begingroup$ Aha, you meant one dimension vector by h. $\endgroup$ – user145959 Mar 2 '19 at 13:37
  • $\begingroup$ Yes. That is right. $\endgroup$ – Kiritee Gak Mar 2 '19 at 14:00

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.