1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Learning for Text with PyTorch

Connected

Exercise

Creating a RNN model for text generation

At PyBooks, you've been tasked to develop an algorithm that can perform text generation. The project involves auto-completion of book names. To kickstart this project, you decide to experiment with a Recurrent Neural Network (RNN). This way, you can understand the nuances of RNNs before moving to more complex models.

The following has been imported for you: torch, torch.nn as nn.

The data variable has been initialized with an excerpt from Alice's Adventures in Wonderland by Lewis Carroll.

Instructions

100 XP
  • Include an RNN layer and linear layer in RNNmodel class
  • Instantiate the RNN model with input size as length of chars, hidden size of 16, and output size as length of chars.