Data for the described procedure was downloaded from Kaggle . This dataset contains articles published in the New York Times from April 2017 to April 2018. Divided according to the month of publication. The dataset is in the form of a .csv file that contains the URL of the published article along with other details. Any random URL was chosen for the tutorial, and then when visiting that URL, the text was copied into a text file and that text file was used for the tutorial.
Step 1: Import the required libraries
|
Step 2: Load data into string
|
Step 3: Create a mapping of each unique character in the text to a unique number
|
Step 4: Data preprocessing
|
Step 5: LSTM Networking
|
Step 6: Define some helper functions to be used during network training
Note that the first two functions and the ones below were obtained from the documentation of the official text generation example from the Keras team .
a) Helper function for fetching the next character:
|
|
c) Helper function to save the model after every epoch in which losses decrease
|
d) Helper function to reduce learning rate every time learning plateau
|
Step 7: Train the LSTM
|
|
Shop
Latest questions