Skip to content
Generate any kind of text with Character Embedding and RNN in pure Numpy
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.
tests Add unit tests Jul 26, 2019
.gitignore Initial commit Jul 15, 2019

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
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/

Start training

python -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 -m model-files/char_rnn_epoch3.pkl -s i

See the other arguments.


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


Run unit tests with

python tests/


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.


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.

You can’t perform that action at this time.