A python script that uses deep learning to generate text - inspired by this blog post.
This script uses a Long short-term memory (LSTM) model and the parameters can be tweaked in /utils/constants.py
.
You can provide a text file that will serve as the input for the algorithm to start learning.
- Make sure to save your input file in
/input
- Update the filename of
INPUT_FILE
in/utils/constants.py
.
Update the directory of WEIGHTS_FILE
in /utils/constants.py
.
- If the weights file already exists, weights will be loaded from file when generating text.
- If the weights file does not yet exist, weights will be generated and saved to the provided file name before generating text.
First install packages by running
$ ./build
To start generating text, run
$ source ./env/bin/activate
$ python generate_text.py
To deactivate the virtualenv when done, run
$ deactivate
This repo contains an input file and some weights for generating Christmas Greetings. Very handy for writing some funny AI generated Christmas cards.
Make sure to set the following values in /utils/constants.py
and you're good to go.
INPUT_FILE = "./input/christmas_greetings.txt"
WEIGHTS_FILE = "./weights/greetings_generator_50epochs.h5"
SEQUENCE_LENGTH = 50
Here's an example of Christmas Greetings the model can output.
Happy holidays.
Whishing you every happiness this christmas bnd throughout the new year ahead.
Have an ideal christmas an occasion that io celebrated as a reflection of your values, desires, affections, traditions.
Special thanks to Codebar Brighton for organising a Christmas show and tell which motivated me to finally have a play with machine learning.