Demo ProjectsNeural NetworksRecurrent Neural NetworksTensorflow

Learn and Generate Shakespeare with TensorFlow RNN

Project Overview

This is by far one of the coolest machine learning examples I’ve come across. This project demonstrates how to create and train a recurrent neural network using TensorFlow to learn reading and writing based solely on the works of Shakespeare!

You can launch this project in minutes on JetML and start playing with it yourself. It’s also easy to replace the Shakespeare plays with scripts from your favorite TV show or movie and synthesize new scenes that have never been read before. So cool…

Getting Started

Make sure you’ve signed up for a JetML account and that you have enough credits to run the project, then click the “Launch on JetML” button below.

Make sure you keep the project in Python 3. Also, I highly recommend using a GPU server to help speed up the training time. 

Training the Model

When your server is ready and in the “running” status (about 5-10 min), click to open your server’s Jupyter notebooks.

Open the TRAIN_MODEL.ipynb notebook and click the run button.

And that’s all you need to do!

You should start seeing the output of the model as it trains.

Since the neural network starts from a random state, the initial outputs are pure gibberish. However, the GPU will make quick work of training the network.

Within a few batches, the network has already started learning sentence structure and punctuation.

After about 10 minutes of training, the network starts to introduce characters and set up scenes, all with decent English! You’ll even notice new character names being created.

How to Adapt This Project

Try replacing the Shakespeare dialogue with scripts from your favorite movies and show. All you have to do is replace the .txt files in the shakespeare directory and re-run the project.

Let me know in the comments below if you’d like to see a Rick and Morty version of this project. I’m having a hard time waiting for season 4 😉

Software Used

Tensorflow, Jupyter Notebook, Python 3

Recommended Servers

Single or Multi GPU

Github Source

Source Author

Martin Görner 

What to learn more about this project?

Watch Martin Görner’s full explanation of the code and how it works (2.5 hrs).

nick@jetml.com

nick@jetml.com

JetML was founded in 2018 by Nicholas Mote, a tech leader and machine learning evangelist based in Portland, Oregon. Nick came to machine learning while solving complex pricing and operations problems for vacation rental management firm Vacasa.

Leave a Reply