Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update poem-generator #1

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
83e4452
upload corpus.txt, corpus_cleaner.py, and rhymes.txt
tfavory Oct 4, 2018
36656ca
upload rhyme_generator.py and its notebook
tfavory Oct 4, 2018
d195e4f
Update README.MD
tfavory Oct 4, 2018
1e8ff96
upload generated poems
tfavory Oct 18, 2018
bd28ec8
update README
tfavory Nov 4, 2018
b9fd902
Create README.md
tfavory Nov 4, 2018
17024ab
Upload ppoem_model.ipynb and rhyme_model.ipynb
tfavory Nov 4, 2018
cefcbba
Upload the corpus.txt and rhymes.txt
tfavory Nov 4, 2018
9bcbed4
Delete corpus.txt
tfavory Nov 4, 2018
f5a4635
Delete poem_generator.py
tfavory Nov 4, 2018
4d5e882
Delete rhyme_generator.py
tfavory Nov 4, 2018
4079dae
Deleter rhymes.txt
tfavory Nov 4, 2018
08b2cf8
Relocate and rename corpus_cleaner.py
tfavory Nov 4, 2018
0940443
poem_generator.ipynb
tfavory Nov 4, 2018
1167877
Delete GRU-poems(incomplete).html
tfavory Nov 4, 2018
2f87f86
Delete LSTM-poems.html
tfavory Nov 4, 2018
4ecb8e0
Delete rhyme_generator.ipynb
tfavory Nov 4, 2018
4b62766
Update README.md
tfavory Nov 4, 2018
2d09e39
Update README.md
tfavory Nov 4, 2018
71ec9bc
Update README.md
tfavory Nov 4, 2018
abeb966
Uploaded weights
tfavory Nov 10, 2018
2f17f8c
Update README.MD
tfavory Nov 10, 2018
901aad2
Update poem_generator.ipynb
tfavory Nov 10, 2018
378671f
update poem_generator.ipynb
tfavory Nov 10, 2018
aa00da8
update poem_generator, upload corpus and rhymes
tfavory Nov 10, 2018
19560e3
Delete word2idx_rhymes.npy
tfavory Nov 24, 2018
8d88ab5
Delete rhymes.txt from the root
tfavory Nov 24, 2018
01d3230
Delete idx2word_rhymes.npy
tfavory Nov 24, 2018
d5082b0
Delete idx2char_poems.npy
tfavory Nov 24, 2018
8477dab
Delete hyperparameters_rhymes.npy
tfavory Nov 24, 2018
301fae8
Delete hyperparameters_poems.npy
tfavory Nov 24, 2018
68937d2
Delete gru_weights_rhymes.npy
tfavory Nov 24, 2018
647476b
Delete gru_weights_poems.npy
tfavory Nov 24, 2018
dcab1f8
Delete fc_weights_rhymes.npy
tfavory Nov 24, 2018
2cc1331
Delete fc_weights_poems.npy
tfavory Nov 24, 2018
99a3e36
Delete embedding_weights_rhymes.npy
tfavory Nov 24, 2018
07c312d
Delete embedding_weights_poems.npy
tfavory Nov 24, 2018
87b90e4
Delete corpus.txt from root
tfavory Nov 24, 2018
845df3a
Delete char2idx_poems.npy
tfavory Nov 24, 2018
e84f3ca
Update README.md
tfavory Nov 24, 2018
53b1866
Update rhyme_model.ipynb and poem_model.ipynb
tfavory Nov 24, 2018
d22f301
Upload poem_generator.ipynb and model_poems.npy
tfavory Nov 24, 2018
b1ae364
Upload poe_cleaned.txt
tfavory Nov 24, 2018
1b70dd2
Update README.md
tfavory Nov 24, 2018
35e4587
Upload model_rhymes.npy
tfavory Nov 24, 2018
26ad768
Update README.md
tfavory Nov 26, 2018
18cf2dd
Update README.md
tfavory Nov 26, 2018
dd182b2
Merge pull request #1 from tfavory/tfavory-patch-1-test-pulls
tfavory Nov 26, 2018
cd297e2
Update README.md
tfavory Nov 26, 2018
3cbf0b6
Merge pull request #2 from tfavory/tfavory-patch-1-test-pulls
tfavory Nov 26, 2018
329466b
Add speech_to_poem.py
tfavory Dec 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pmlg-poem-generator

This is a poem generator trained with Gated Recurrent Units (GRU) on a corpus of poems including those in:
This is a poem generator trained with Gated Recurrent Units (GRU) on a corpus of poems including:
* [Poems Every Child Should Know](http://www.gutenberg.org/ebooks/16436), by Mary E. Burt
* [Poems](http://www.gutenberg.org/ebooks/52546), by Thomas Hall Shastid
* [Poems of Progress and New Thought Pastels](http://www.gutenberg.org/ebooks/3228), by Ella Wheeler Wilcox
Expand All @@ -12,20 +12,40 @@ Most of the code comes from [Tensorflow's text generation tutorial](https://gith

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:
* Clean the corpus
* Find more data
* Save a model
* Try LSTM
* Train a model based on sequences of words instead of characters
* Update weights with another corpus
* Try data from [GutenTag](http://www.cs.toronto.edu/~jbrooke/gutentag/)
* Train a model based on sequences of words instead of characters (memory issues)

### Middle term goals:
* Create a rhyme generator
* Train a model backward: from the last word to the first

The idea is to generate the rhymes first, and then write the lines from the last word to the first. This process makes sure that the generated poems rhyme.
* Try Bi-directional models (failed to train a model conform to [Tensorflow's text generation tutorial](https://github.com/tensorflow/tensorflow/blob/r1.10/tensorflow/contrib/eager/python/examples/generative_examples/text_generation.ipynb).)

### Long term goals
* Style transfert
* Generate other kind of text (Haiku, magazines, articles, books...)
Binary file added model_poems.npy
Binary file not shown.
Binary file added model_rhymes.npy
Binary file not shown.
13 changes: 13 additions & 0 deletions model_training/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Train your own poem generator model

There are notebooks of interest here:
* A poem generator called *poem_model*. It trains a model that generates text backwards (from the last letter to the first). The idea is to use it with a rhyme generator.
* A rhyme generator called *rhymes_model*. It trains a rhyme generator supposed to return lists of words that rhyme

The first notebook relies on a corpus of poems named 'corpus.txt'

The second notebook will take 'rhymes.txt' as a database of rhymes.

Note that 'rhymes.txt' is nothing but the rhymes extracted from 'corpus.txt', with the help of corpus2rhymes.py.

Note also that corpus2rhymes.py performs some preliminary corpus cleaning as well. Note that it is not perfect.
Loading