Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 2.24 KB

README.md

File metadata and controls

51 lines (33 loc) · 2.24 KB

pmlg-poem-generator

This is a poem generator trained with Gated Recurrent Units (GRU) on a corpus of poems including:

Most of the code comes from Tensorflow's text generation tutorial.

Please refer to the notebook for an overview of the results.

How to generate poetry?

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

How to train your own model

(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'

Improvement ideas

Short term:

  • Update weights with another corpus
  • Try data from GutenTag
  • Train a model based on sequences of words instead of characters (memory issues)

Middle term goals:

Long term goals

  • Style transfert
  • Generate other kind of text (Haiku, magazines, articles, books...)