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

Connected

Exercise

Shakespearean language encoder

With the preprocessed Shakespearean text at your fingertips, you now need to encode it into a numerical representation. You will need to define the encoding steps before putting the pipeline together. To better handle large amounts of data and efficiently perform the encoding, you will use PyTorch's Dataset and DataLoader for batching and shuffling the data.

The following has been loaded for you: torch, nltk, stopwords, PorterStemmer, get_tokenizer, CountVectorizer, Dataset, DataLoader, and preprocess_sentences.

The processed_shakespeare from the Shakespearean text is also available to you.

Instructions 1/3

undefined XP
    1
    2
    3
  • Define a ShakespeareDataset dataset class and complete the __init__ and __getitem__ methods.