Source

GitHub · char-rnn: Multi-layer Recurrent Neural Networks (LSTM, GRU, RNN) for character-level language models in Torch

Open the source

This README describes char-rnn, Karpathy's Torch code for training multi-layer RNN/LSTM/GRU character-level language models and sampling text from them. Beyond usage, he teaches practical training wisdom: match parameter count to dataset size, monitor training vs. validation loss to diagnose over/underfitting, and pick the checkpoint with the lowest validation loss.

- The model learns to predict the next character from a single text file and can then generate similar text character by character. - Small datasets (1MB or less) make learning ineffective, while larger datasets justify bigger models. - Checkpoint filenames encode validation loss, and the lowest-loss checkpoint, not necessarily the last, should be used. - seq_length limits how far gradients backpropagate, so datasets with long-term dependencies need longer sequences. - Temperature trades off conservative, likely output against diverse output with more mistakes. - The best strategy is to make the network as large as you can afford and tune dropout, selecting by validation performance.

Based on Andrej Karpathy's public content. Not affiliated with or endorsed by Andrej Karpathy.

Supports these rules

Quotes from this video

“The most important quantity to keep track of is the difference between your training loss (printed during training) and the validation loss”

“If your training/validation loss are about equal then your model is **underfitting**.”

“you will want to use the model checkpoint that reports the lowest validation loss.”

“Notice that this might not necessarily be the last checkpoint at the end of training (due to possible overfitting).”

“always err on making the network larger (as large as you're willing to wait for it to compute) and then try different dropout values (between 0,1).”

“Make sure you have a decent amount of data in your validation set or otherwise the validation performance will be noisy and not very informative.”

“I would advise that you always use `num_layers` of either 2/3. The `rnn_size` can be adjusted based on how much data you have.”

Topics