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

Adding a new notebook for text generation using RNN #158

Merged
merged 6 commits into from
Feb 8, 2022

Conversation

sanjanalreddy
Copy link
Collaborator

@sanjanalreddy sanjanalreddy commented Feb 1, 2022

Adding a new notebook as part of the NLP offering. This is a really nice notebook which shows how text can be generated using an RNN. This will be a perfect stepping stone for students to learn how text generation works. This notebook was adapted from this tensorflow tutorial .

This notebook uses sub-classing, as part of the slides, I will also add a brief lecture on how subclassing is done.

Currently, only the solution notebook is part of this PR. Once I incorporate review comments, I will create a corresponding lab notebook.

Please review!

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -0,0 +1,1433 @@
{
Copy link
Collaborator

@BenoitDherin BenoitDherin Feb 3, 2022

Choose a reason for hiding this comment

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

  • " Create training examples and targets" -> " Create training examples and targets for text generation"

Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,1433 @@
{
Copy link
Collaborator

@BenoitDherin BenoitDherin Feb 3, 2022

Choose a reason for hiding this comment

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

nit: Consider putting the comments in fully fledge sentences in markdown above rather than in the code. I personally find that too many comments within the code tend to make it harder to read, especially when it's obvious. For instance, since it's very clear that print(f"Length of text: {len(text)} characters") does, I would not add a comment explaining we are printing the length of text.


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good! Cleaned up comments throughout the whole lab. Thank you!

@@ -0,0 +1,1433 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove comment or put them in markdown


Reply via ReviewNB

@@ -0,0 +1,1433 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove comment or put them in markdown


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@@ -0,0 +1,1433 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!


Reply via ReviewNB

@@ -0,0 +1,1433 @@
{
Copy link
Collaborator

@BenoitDherin BenoitDherin Feb 3, 2022

Choose a reason for hiding this comment

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

  • I'd remove all the TODOs and reserve them for the exercise notebook.
  • Maybe add a brief sentence above this class in a markdown cell, explaining that 1) we need to derive from tf.keras.Model, 2) in the constructor we define the layers, and 3) in the call method we define the pass forward using the layers defined in the constructor
  • I'd remove line 14: x = inputs, and pass directly inputs to self.embedding
  • Maybe add a comment on over line 16, explaining what that state logic in 16-18 does (here I think it's warranted to add the comment in the code directly). Maybe this can also be explained in a markdown cell.

Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done! Took all your suggestions!

@@ -0,0 +1,1433 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd remove the TODO.


Reply via ReviewNB

@BenoitDherin
Copy link
Collaborator

Super nice notebook! It all ran fine for me. I added minor comments and suggestions.

@sanjanalreddy sanjanalreddy merged commit 70259a0 into master Feb 8, 2022
@sanjanalreddy sanjanalreddy deleted the text_generation_rnn branch February 8, 2022 18:40
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.

2 participants