Skip to content

[Keras] Support return_sequences in LSTM#9303

Merged
vinx13 merged 1 commit intoapache:mainfrom
apivovarov:lstm
Oct 19, 2021
Merged

[Keras] Support return_sequences in LSTM#9303
vinx13 merged 1 commit intoapache:mainfrom
apivovarov:lstm

Conversation

@apivovarov
Copy link
Contributor

@apivovarov apivovarov commented Oct 15, 2021

This PR adds support for return_sequences bool param for Keras LSTM layer.
By default the param is False - LSTM returns only the last h output
If return_sequences is True then ALL h outputs should be returned. The outputs should be concatenated along axis 1.

I also added dedicated test for LSTM. Input shape increased to test return_sequences is True case.

return_sequences = True is needed if your model has two or more LSTM layers. By Default LSTM layer takes 3D tensor and returns 2D tensor. To connect two LSTM layers together the first layers should return 3D tensor. It can be achieved if return_sequences param set to True.

Understanding LSTM Networks

Related discussion https://discuss.tvm.apache.org/t/keras-lstm-return-sequences-parameter-not-supported/11239

@apivovarov
Copy link
Contributor Author

@Huyuwei @mbrookhart @kazum @yongwww Guys, can you help to review this PR?

Copy link
Contributor

@AndrewZhaoLuo AndrewZhaoLuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@Mousius Mousius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, cc @leandron @mbaret

@vinx13 vinx13 merged commit 31c171e into apache:main Oct 19, 2021
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants