Through the use of Long Short-Term Memory (LSTM) Networks, we aim to model the English language as closely as possible, such that model created is able to generate coherent sequences of words, namely, sentences. To achieve this, every word is transformed into a feature vector, which is used as input. Its corresponding output is the next most probable word to follow. The network will learn these probabilities through the use of a large list of human-generated sentences, more specifically the novel "Twelve Short Mystery Stories” by Sapper (Ronald Standish) 1.
Python 3.6.1Tensorflow 1.3.0Keras 2.1.2matplotlib 2.0.2numpy 1.12.1
Directory Path: /src/scripts/
-
Train the model:
python train.py [-h] [-v] [--data DATA] [--epochs EPOCHS] [--temp TEMP] [--slen SLEN] [-win WIN]Optional arguments:
-h,--helpshow help message and exit -v,--versionshow program's version number and exit --data DATApath to training data (default: sample_data_short.txt)--epochs EPOCHSnumber of epochs to train for (default: 50) --temp TEMPselect temperature value for prediction diversity (default: 1.0) --slen SLENmaximum length for a training sequence (default: 15) -win WINselect sliding window for text iteration and data collection for training (default: 3) -
Make predictions:
python predict.py [-h] [-v] [--data DATA] [--seed SEED] [--nwords NWORDS] [--temp TEMP] [--slen SLEN] [-win WIN]Optional arguments:
-h,--helpshow help message and exit -v,--versionshow program's version number and exit --data DATApath to training data (default: sample_data_short.txt)--seed SEEDprovide a word or sentence to seed the program with --nwords NWORDSnumber of words to generate (default: 400) --temp TEMPselect temperature value for prediction diversity (default: 1.0) --slen SLENmaximum length for a training sequence (default: 15) -win WINselect sliding window for text iteration and data collection for training (default: 3)
1: This novel is available on the Project Gutenberg website.
