EbookQA
ProcessAdvanced

How is the training dataset prepared for the LSTM model according to the chapter?

The training dataset for the LSTM model is prepared by loading and filtering the Epicurious Recipes dataset to include only recipes with a title and description. The text data is then vectorized using a TextVectorization layer, which converts text to lowercase, assigns integer tokens to the most common 10,000 words, and pads or clips sequences to a length of 201 tokens. The training set consists of input sequences of recipe tokens and target sequences that are the same vectors shifted by one token.

The preparation of the training dataset for the LSTM model involves several steps. First, the Epicurious Recipes dataset is loaded and filtered to retain only those recipes that have both a title and a description. This filtered data is then processed using a TextVectorization layer, which standardizes the text to lowercase, assigns integer tokens to the 10,000 most frequent words, and adjusts the sequences to a uniform length of 201 tokens by padding or clipping. The training dataset is created by mapping the text data into input and target pairs, where the input is a sequence of tokens and the target is the same sequence shifted by one token. This setup allows the model to learn to predict the next word in a sequence based on the preceding words.

Key points

  • Epicurious Recipes dataset is used, filtered for title and description.
  • Text is vectorized to lowercase and tokenized into integers for the top 10,000 words.
  • Sequences are padded or clipped to 201 tokens.
  • Training set consists of input sequences and target sequences shifted by one token.
  • TextVectorization layer handles tokenization and sequence length adjustment.
Source:Generative Deep Learning: Teaching Machines to Paint, Write, Compose, and Play· Autoregressive Models· p. 160–173

Related questions

Cover of Generative Deep Learning: Teaching Machines to Paint, Write, Compose, and Play

Generative Deep Learning: Teaching Machines to Paint, Write, Compose, and Play

David Foster;

Second Edition · O’Reilly Media, Inc.

View this ebook