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.

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

`sudo easy_install pip`
`sudo easy_install --upgrade six`
`export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.1-py2-none-any.whl`
`sudo pip install --upgrade \$TF_BINARY_URL`

# Step 4: Train the model

`source ~/tensorflow/bin/activate`
`cd ~/desktop/word-rnn-tensorflow-master`
`python train.py`

# 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’)`
`python sample.py`

# 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.

--

--

## More from Deep Writing

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