Generating song lyrics using LSTM RNN

Now, we will see how to use the LSTM network to generate Zayn Malik's song lyrics. The dataset can be downloaded from here (https://github.com/sudharsan13296/Hands-On-Reinforcement-Learning-With-Python/blob/master/07.%20Deep%20Learning%20Fundamentals/data/ZaynLyrics.txt) ,which has a collection of Zayn's song lyrics.

First, we will import the necessary libraries:

import tensorflow as tfimport numpy as np

Now, we will read our file containing the song lyrics:

with open("Zayn_Lyrics.txt","r") as f:    data=f.read()    data=data.replace('\n','')    data = data.lower()

Let's see what we have in our data:

data[:50]"now i'm on the edge can't find my way it's inside "

Then, we store all the characters in the all_chars ...

Get Hands-On Reinforcement Learning with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.