Deep Writing
Published in

Deep Writing

How to write with artificial intelligence

An easy guide to “Deep Writing” without writing any code

“Dumbledore will get out from behind a cream cake” — Harry Potter: Written by Artificial Intelligence

Thus, I’ve made this quick tutorial to teach you how to create your own instances of “Deep Writing”. This is not going to be an in-depth description of the underlying technology — but instead, a step-by-step guide that anybody can follow (even if you have no coding or machine learning experience).

Step 0: Understanding the simple intuition

Here is a very crude approximation of what is involved in the Deep Writing process. More than anything, this is meant to give you enough intuition and appreciation to follow along with the rest of the tutorial.

  1. You show a computer some sample text (for example, the Harry Potter books).
  2. The computer identifies all the unique words in the sample text.
  3. The computer groups words based on how often they appear together in the sample text (using a particular mathematical model). This is the “learning” portion of “Deep Learning”.
  4. You pick a starting word (for example, “The”).
  5. Using what it learned in Step 3, you ask the computer to guess the word most likely to come after the starting word (i.e. “The”). This is recorded as the second word.
  6. Then, based on the first two words, you ask the computer to guess the third word. And so on.
  7. Eventually, you tell the computer to stop guessing after many words, and you have successfully created your Deep Writing.

Step 1: Download the code

We are going to use code written by Sung Kim (who teaches computer science at HKUST). This code is very similar to the code I used, but is a little bit more generally applicable.

Step 2: Customize the sample text

Open the file input.txt, which you can find in word-rnn-tensorflow-master > data > tinyshakespeare > input.txt. Then, delete all the text in the file, and replace it with the sample text that you want to use. Make sure you save the updated file.

Step 3: Install TensorFlow

TensorFlow is a machine learning library made by Google. We need to download it in order to run our code.

sudo easy_install pip
sudo easy_install --upgrade six
sudo pip install --upgrade $TF_BINARY_URL

Step 4: Train the model

With TensorFlow downloaded on your computer, it’s time to train your model (i.e. “group” words based on patterns).

source ~/tensorflow/bin/activate
cd ~/desktop/word-rnn-tensorflow-master

Step 5: Create the “Deep Writing”

Once your model finishes training, it’s finally time to create the Deep Writing.

parser.add_argument(‘-n’, type=int, default=200, help=’number of words to sample’)
parser.add_argument(‘-n’, type=int, default=1500, help=’number of words to sample’)

Step 6: Submit your Deep Writing for publication

I created a publication on Medium to collect interesting examples of Deep Writing. If you create Deep Writing that you want to share, Tweet me a link, and I’ll added it the publication.

Max Deutsch is the co-founder of Monthly — an online education platform that partners with some of the world’s biggest YouTubers to create one-month, highly-immersive online classes.

If you want to follow along with Max’s year-long accelerated learning project, make sure to follow this Medium account.



Stories, songs, and speeches written by deep learning (artificial intelligence)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store