Switch branches/tags
Nothing to show
Find file History
Latest commit 89d8ad5 Jan 1, 2018
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
README.md update filename in readme Jan 1, 2018
char-rnn-generation.ipynb Fixes error of #22, #15 in Jupyter Notebook Jul 8, 2017
generate.py improve saving model; update readme Mar 16, 2017
helpers.py slight cleanup Mar 16, 2017
model.py improve saving model; update readme Mar 16, 2017
train.py unnecessary output.view; fixes #22, fixes #15 May 20, 2017

README.md

Practical PyTorch: Generating Shakespeare with a Character-Level RNN

Dataset

Download this Shakespeare dataset (from Andrej Karpathy's char-rnn) and save as shakespeare.txt

Jupyter Notebook

The Jupyter Notebook version of the tutorial describes the model and steps in detail.

Python scripts

Run train.py with a filename to train and save the network:

> python train.py shakespeare.txt

Training for 2000 epochs...
(10 minutes later)
Saved as shakespeare.pt

After training the model will be saved as [filename].pt — now run generate.py with that filename to generate some new text:

> python generate.py shakespeare.pt --prime_str "Where"

Where, you, and if to our with his drid's
Weasteria nobrand this by then.

AUTENES:
It his zersit at he

Training options

Usage: train.py [filename] [options]

Options:
--n_epochs         Number of epochs to train
--print_every      Log learning rate at this interval
--hidden_size      Hidden size of GRU
--n_layers         Number of GRU layers
--learning_rate    Learning rate
--chunk_len        Length of chunks to train on at a time

Generation options

Usage: generate.py [filename] [options]

Options:
-p, --prime_str      String to prime generation with
-l, --predict_len    Length of prediction
-t, --temperature    Temperature (higher is more chaotic)