Skip to content

Move the tf.keras.layers.PeepholeLSTMCell to tfa #1944

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

Merged
merged 13 commits into from
Jun 26, 2020

Conversation

qlzh727
Copy link
Member

@qlzh727 qlzh727 commented Jun 20, 2020

This cell was exported under tf core API as an experimental since 2.0, but I think tfa should be a better place for this implementation.

We are planing to deprecate and eventually remove the PeepholeLSTMCell in the tf core API once this is landed.

Rebase the against upstream
This reverts commit 63d83d2.
This cell was exported under tf core API as an experimental since 2.0, but I think tfa should be a better place for this implementation.

We are planing to deprecate and eventually remove the PeepholeLSTMCell in the tf core API once this is landed.
@bot-of-gabrieldemarmiesse

@pedrolarben

You are owner of some files modified in this pull request.
Would you kindly review the changes whenever you have the time to?
Thank you very much.

@qlzh727
Copy link
Member Author

qlzh727 commented Jun 22, 2020

@seanpmorgan, currently the CI test is failed for 2 reasons https://github.com/tensorflow/addons/pull/1944/checks?check_run_id=796216452.

  1. The typehint is not available for the new cell, since it was using the init from the keras LSTMCell. For a class doesn't have its own init(), can we suppress the warning if possible?

  2. The unit test was failing since it is using some tf.compat.v1 API. I was copying the existing test since it was doing some numerical comparison with tf.v1 API for correctness test. Can we somehow allow that?

@gabrieldemarmiesse
Copy link
Member

@qlzh727 Thanks for the pull request!

  1. Sure, we can allow that, no problem. I'll need to modify the library that does the check. In the meantime, you can add this class to the list of exceptions avoid having the tests bothering you: https://github.com/tensorflow/addons/blob/master/tools/testing/source_code_test.py#L40

  2. I see tf.compat.v1 is used three times. I believe it should be possible to find alternatives. Maybe using tf.random.set_seed tf.keras.layers.LSTMCell and tf.keras.initializers.Ones?

@qlzh727
Copy link
Member Author

qlzh727 commented Jun 23, 2020

@qlzh727 Thanks for the pull request!

  1. Sure, we can allow that, no problem. I'll need to modify the library that does the check. In the meantime, you can add this class to the list of exceptions avoid having the tests bothering you: https://github.com/tensorflow/addons/blob/master/tools/testing/source_code_test.py#L40

Sure, will do.

  1. I see tf.compat.v1 is used three times. I believe it should be possible to find alternatives. Maybe using tf.random.set_seed tf.keras.layers.LSTMCell and tf.keras.initializers.Ones?

I can't change to keras.LSTMCell since only the tf.nn.rnn_cell.LSTMCell contains the implementation of peephole. It was the base line for me to verify the numbers. Could we allow the v1.compat in test only?

@gabrieldemarmiesse
Copy link
Member

Yeah that makes sense. In addons, we're trying to show users how to write idiomatic tf 2.x code. Even if tf.compat is not going away anytime soon, we would prefer to use modern, future-proof TF code to minimize the technical debt. This was the rational when we decided to forbid tf.compat. In this case, a good alternative would be to hardcode some numbers in the tests, and check against that. That would prevent any regressions since we know that the current implementation is correct.

qlzh727 added 2 commits June 24, 2020 20:50
We removed the v1 compat API since TFA only works with TF v2.
The cell itself doesn't have __init__ and it  inherit the __init__ from keras.LSTMcell, which doesn't have type hint yet.
@boring-cyborg boring-cyborg bot added the test-cases Related to Addons tests label Jun 25, 2020
@qlzh727
Copy link
Member Author

qlzh727 commented Jun 25, 2020

Yeah that makes sense. In addons, we're trying to show users how to write idiomatic tf 2.x code. Even if tf.compat is not going away anytime soon, we would prefer to use modern, future-proof TF code to minimize the technical debt. This was the rational when we decided to forbid tf.compat. In this case, a good alternative would be to hardcode some numbers in the tests, and check against that. That would prevent any regressions since we know that the current implementation is correct.

Done.

Copy link
Member

@WindQAQ WindQAQ left a comment

Choose a reason for hiding this comment

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

LGTM!

@qlzh727 qlzh727 requested a review from WindQAQ June 26, 2020 03:05
armory-twosix
armory-twosix approved these changes Jun 26, 2020
Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

@seanpmorgan seanpmorgan merged commit ea99e7a into tensorflow:master Jun 26, 2020
ashutosh1919 pushed a commit to ashutosh1919/addons that referenced this pull request Jul 12, 2020
* Move the tf.keras.layers.PeepholeLSTMCell to tfa
This cell was exported under tf core API as an experimental since 2.0, but I think tfa should be a better place for this implementation. 
We are planing to deprecate and eventually remove the PeepholeLSTMCell in the tf core API once this is landed.

* Update peephole lstm cell test with golden values.
We removed the v1 compat API since TFA only works with TF v2.

* Add PeepholeLSTMCell to the exception list for typehint check.
The cell itself doesn't have __init__ and it  inherit the __init__ from keras.LSTMcell, which doesn't have type hint yet.

* Fix format.
* Update build method to be more aligned with py3 style.
jrruijli pushed a commit to jrruijli/addons that referenced this pull request Dec 23, 2020
* Move the tf.keras.layers.PeepholeLSTMCell to tfa
This cell was exported under tf core API as an experimental since 2.0, but I think tfa should be a better place for this implementation. 
We are planing to deprecate and eventually remove the PeepholeLSTMCell in the tf core API once this is landed.

* Update peephole lstm cell test with golden values.
We removed the v1 compat API since TFA only works with TF v2.

* Add PeepholeLSTMCell to the exception list for typehint check.
The cell itself doesn't have __init__ and it  inherit the __init__ from keras.LSTMcell, which doesn't have type hint yet.

* Fix format.
* Update build method to be more aligned with py3 style.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes test-cases Related to Addons tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants