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

Rnn testable doctests #2147

Merged
merged 5 commits into from
Sep 15, 2020
Merged

Conversation

Harsh188
Copy link
Contributor

@Harsh188 Harsh188 commented Sep 3, 2020

Description

Adding testable docstrings to rnn.

Part of #2066

Changes made to:

  • esn_cell.py
  • layer_norm_simple_rnn_cell.py
  • peephole_lstm_cell.py

Type of change

  • Updated or additional documentation

Checklist:

How Has This Been Tested?

Using pytest

@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.

>>> input = tf.keras.Input((100, 100))
>>> output = tf.keras.layers.Layer(input)

<... Note: Values used for timesteps and input_dim have been used purely
Copy link
Member

Choose a reason for hiding this comment

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

Is this warning? I think we can at least print output.

Copy link
Contributor Author

@Harsh188 Harsh188 Sep 4, 2020

Choose a reason for hiding this comment

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

I'll include the output of output but it's only going to be displayed as a Layer object. I think the example tries to depict the context in which the PeepholeLSTMCells can be utilized, it doesn't necessarily demonstrate the full process. That's why I included a short note stating that the values used for input have no significance.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see. Can we change the functional API to

>>> output, state = rnn(input)
>>> output
>>> state

This is much more informative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WindQAQ Sorry for the late reply I somehow missed this comment. When I try

>>> keras.layers.RNN(peephole_lstm_cells,return_state=True)
>>> layer.states

it displays ([None, None], [None, None]). I'm a little confused on how to view the state of the layer.

@WindQAQ
Copy link
Member

WindQAQ commented Sep 12, 2020

@Harsh188 We should canonicalize the example. See the following colab for more details. Note that different cell may have different lengths of state, so when return_state=True, the values to be unpacked may be different. Also, It would be great that we can have this example for all kind of rnn cell in addons :-)

https://colab.research.google.com/drive/1Ndgy5iseSrcBm6tjQGdnLyMhbszvdAM8?usp=sharing

@Harsh188
Copy link
Contributor Author

@WindQAQ Thank you for providing the colab example! I'll get to work on this and implement them for the other rnn cells as well.

@Harsh188
Copy link
Contributor Author

Friendly ping @WindQAQ :)

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.

Thanks.

@WindQAQ WindQAQ merged commit 8320f16 into tensorflow:master Sep 15, 2020
jrruijli pushed a commit to jrruijli/addons that referenced this pull request Dec 23, 2020
* added doctests layer_norm_simple

* added doctests peephole_lstm_cell.py

* minor changes

* including output for example

* Updated examples to be descriptive and standardized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants