Skip to content

kirbiyik/generate-any-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate Any Text

Generate any kind of text with character embedding and RNN in pure Numpy.

Note that this project is not optimized for performance. It is rather a reference implementation for many building blocks of neural networks.

Check this list to reach implemented elements.

Example Training

Clone the repository and change directory into it

git clone https://github.com/kirbiyik/generate-any-text
cd generate-any-text

This project has only 3 dependencies: Numpy for numeric computation, tqdm for progress bar and matplotlib for plotting. You probably already have these. Otherwise run command below.

pip install -r requirements.txt

Download the Trump speeches dataset

wget -P data/ https://github.com/ryanmcdermott/trump-speeches/blob/master/speeches.txt

Start training

python train.py -d data/speeches.txt 

See the other arguments.

Here is an example footage of training. It learns how to generate Trump-like tweets with a 3 minutes training in CPU.

Example Inference

Models will be saved under model-files unless explicitly specified.

python inference.py -m model-files/char_rnn_epoch3.pkl -s i

See the other arguments.

Elements

Click on any item to go to related line of code.

Testing

Run unit tests with

python tests/layers.py

Dataset

Trump speeches dataset is used for demonstration. Though it is possible to use any kind of text file. It does not require any special format. It learns what you feed!

Here is a resource for many free eBooks.

Acknowledgement

This work is heavily based on Stanford's CS 231n Assignments. I've implemented additional layers and features for the special needs of this problem.

About

Generate any kind of text with Character Embedding and RNN in pure Numpy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages