The data for the described procedure is a collection of short and famous poems by famous poets in .txt format. It can be downloaded here .
Step 1: Import the required libraries
|
Step 2: Load data to line
|
Step 3: Create a mapping of each unique character in the text with a unique number
|
Step 4: Data preprocessing
|
Step 5: Building the GRU network
|
Step 6: Define some helper functions to be used during network training
Note that the first two the functions below were obtained from the doc of the official example of text generation from the Keras team .
a) Helper function for fetching the next character:
|
b) helper function for generating text after each epoch
|
|
d) Auxiliary function to reduce the learning rate every time learning plateau
|
Step 7: Train the GRU model
|
Latest questions |