Skip to content
a Keras neural network trained to write Shakespearean sonnets, with a Flask web interface
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Robot Shakespeare

a Keras neural network trained to write Shakespearean sonnets, with an interactive Flask interface.


pip install tensorflow
pip install keras
pip install h5py
pip install Flask
pip install Flask-wtf
pip install gunicorn

Training the network

python network/

The weights will be checkpointed as hdf5 files with the format weights-{epoch:02d}-{loss:.3f}.hdf5 and the model will be dumped as model.yaml. If you wish to use a different corpus, just drop it in & edit network/

Generating text

Edit network/ to use your new weights and model if desired, then:

python network/

Typical output

ake thee of thy sweet self dost see,
From heaven thee, as the beauty of thy didge?
Then were thou art my love whose soor coll, and she vounes,
That in my stars in his praise the ever wor,
Whose whould his spiret the deser thee is bart,
  And thou thy self dost thou mayst live in thee
  Then do I not the wrose to deepile lease.

The worthous shalt be bland nor my seas,
With pentter than the owness doth bear,
Where that beauty like of many a forming.
Thou art as find in that which the thing thee,

Running the Flask app


If you wish to use different weights and model than I did, put them in app/static/model.yaml and app/static/weights.hdf5

Heroku deployment

Should be as easy as:

heroku create
git push heroku master

You may need to heroku ps:scale web=1 if it doesn't do so automatically.

You can’t perform that action at this time.