Skip to content
AI Composer for Machine Learning for Hackers #2
Branch: master
Clone or download
Latest commit 434817d Sep 19, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
generated_music/mp3 added nottingham sample Mar 31, 2016
.gitignore added images Mar 31, 2016 Update Sep 19, 2016 fix error May 9, 2016 added some documentation Mar 31, 2016 added some documentation Mar 31, 2016 first May 8, 2016 some more documentation cleanup Mar 31, 2016 added rnn allg Mar 27, 2016


A project that trains a LSTM recurrent neural network over a dataset of MIDI files. More information can be found on the writeup about this project. This the code for 'Build an AI Composer' on Youtube


Use pip to install any missing dependencies

Installation (Tested on Ubuntu 16.04)

You will see "export TF_BINARY_URL" followed by a URL. Modify the part of the url that has "tensorflow-0.10.0", so that it will download version 0.8.0, not version 0.10.0 "tensorflow-0.8.0.

Example of the modified url, for the Python 2.7 CPU version of Tensorflow:


sudo pip install --upgrade $TF_BINARY_URL

Follow the third step normally to install Tensorflow.

  • Step 2: After installing Tensorflow, you will have to install the missing dependencies:

pip install matplotlib

sudo apt-get install python-tk

pip install numpy

  • Step 3:
cd ~
git clone
cd python-midi
python install
cd ~
git clone
cd python-mingus
python install

Basic Usage

  1. mkdir data && mkdir models
  2. run 'python'. This will collect the data, create the chord mapping file in data/nottingham.pickle, and train the model
  3. Run python --config_file new_config_file.config to generate a new MIDI song.

Give it 1-2 hours to train on your local machine, then generate the new song. You don't have to wait for it to finish, just wait until you see the 'saving model' message in terminal. In a future video, I'll talk about how to easily setup cloud GPU training. Likely using


Credit for the vast majority of code here goes to Yoav Zimmerman. I've merely created a wrapper around all of the important functions to get people started.

You can’t perform that action at this time.