In the sentiment-classification recipes that we performed in Chapter 11, Building a Recurrent Neural Network, we were trying to predict a discrete event (sentiment classification). This falls under the many-to-one architecture. In this recipe, we will learn how to implement a many-to-many architecture, where the output would be the next possible 50 words of a given sequence of 10 words.
Generating text
Getting ready
The strategy that we'll adopt to generate text is as follows:
- Import project Gutenberg's Alice's Adventures in Wonderland dataset, which can be downloaded from https://www.gutenberg.org/files/11/11-0.txt.
- Preprocess the text data so that we bring every word to the same case, and remove punctuation...