Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay][Frontend] Fix tensorflow frontend lstm forget bias adding order #3410

Merged
merged 2 commits into from
Jun 27, 2019

Conversation

ttyang1018
Copy link
Contributor

Recently, I tried to convert my own RNN model trained with TF into TVM.

I found out the TF frontend code with LSTMBlockCell conversion have a bug.

According to TF's implementation, (line 59 - line 76)
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/rnn/python/ops/lstm_ops.py

forget_gate f should adding forget_bias first, then doing the sigmoid operation. However, in the relay's frontend conversion code, the forget_gate is doing sigmoid first then add with forget_bias.

I have checked with TF_forward test case, since in the LSTM and PTB test case, the forget_bias is set to 0.0, so the test case couldn't detect this bug.

I changed the order on my own, and get the correct prediction on my own model.

# The first commit's message is:

fix tensorflow frontend lstm forget bias adding order

# This is the 2nd commit message:

remove trailing space for merge
@ttyang1018 ttyang1018 changed the title fix tensorflow frontend lstm forget bias adding order [RELAY][FrontEnd] Fix tensorflow frontend lstm forget bias adding order Jun 24, 2019
@ttyang1018 ttyang1018 changed the title [RELAY][FrontEnd] Fix tensorflow frontend lstm forget bias adding order [Relay][FrontEnd] Fix tensorflow frontend lstm forget bias adding order Jun 24, 2019
@ttyang1018 ttyang1018 changed the title [Relay][FrontEnd] Fix tensorflow frontend lstm forget bias adding order [Relay][Frontend] Fix tensorflow frontend lstm forget bias adding order Jun 24, 2019
@srkreddy1238
Copy link
Contributor

@ttyang1018 Thanks for reporting and also providing a fix.

Can you help to ass a regression test case for the same ?

@ttyang1018
Copy link
Contributor Author

@ttyang1018 Thanks for reporting and also providing a fix.

Can you help to ass a regression test case for the same ?

OK. I modified the original TF LSTM test case. Using non-zero forget bias 0.5 instead, and get pass in the unit test.

@tqchen tqchen merged commit 7db5779 into apache:master Jun 27, 2019
@tqchen
Copy link
Member

tqchen commented Jun 27, 2019

THanks, @ttyang1018 @srkreddy1238 , this PR is now merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants