This is a poem generator trained with Gated Recurrent Units (GRU) on a corpus of poems including:
- Poems Every Child Should Know, by Mary E. Burt
- Poems, by Thomas Hall Shastid
- Poems of Progress and New Thought Pastels, by Ella Wheeler Wilcox
- Poems Teachers Ask For
- Poems Teachers Ask For, Book Two
- The Pied Piper of Hamelin, and Other Poems, by Robert Browning
Most of the code comes from Tensorflow's text generation tutorial.
Please refer to the notebook for an overview of the results.
Use the pretrained model called poem_generator.
- In the same folder, save the notebook called poem_generator.ipynb and the 2 npy files: model_poems.npy, and model_rhymes.npy
- Run poem_generator.ipynb
Disclaimer: Saving the model with npy files is probably less efficient than loading a Checkpoint, but I did not manage to do it
(optional) if you want to train a model on your own text files:
- Find some text, called the file 'poem_corpus.txt'
- Run corpus_cleaner.py. It should create two text files: 'corpus.txt', and 'rhymes.txt'.
To train a model:
- Run 'rhyme_model.ipynb'. It creates 6 npy files that store the weigths of your rhyme model.
- Run 'poem_model.ipynb'
- Run 'poem_generator.ipynb'
- Update weights with another corpus
- Try data from GutenTag
- Train a model based on sequences of words instead of characters (memory issues)
- Try Bi-directional models (failed to train a model conform to Tensorflow's text generation tutorial.)
- Style transfert
- Generate other kind of text (Haiku, magazines, articles, books...)