This walkthrough demonstrates how to “do” deep learning in Python on some music tasks that may be more interesting to those in the MIR community. To get the most out of this exercise, the reader should already possess a reasonable grasp of basic concepts and terminology; if this isn’t the case, we recommend reviewing any and all information found at the deep learning homepage before proceeding.
That said, this prerequisite knowledge is not strictly necessary to complete the tutorial, and you may still find the exercise worthwhile without it.
Contents
Code Repository
Data
Setting up Your System
Mac OS X
Linux
Windows
Testing your Setup
Troubleshooting
Virtualization
Next Steps
Additional Resources
Code Repository
All code contained in this tutorial are provided in a git repository hosted on BitBucket. The first thing you’ll want to do is clone it locally with the following from the command line:
$ cd /some/directory/
$ git clone https://ejhumphrey@bitbucket.org/ejhumphrey/dltutorial.git
$ cd dltutorial
We’ll assume for the remainder of these walkthroughs that you are operating out of this directory.
Data
For your machine learning enjoyment, we provide two datasets that will work seamlessly with the provided source code:
Monophonic Instrument Features
Chord Annotated Magnitude DFT Coefficients
Setting up Your System
The provided source code has the following dependencies, which must be installed and configured:
Python 2.7
Numpy >= 1.8
Scipy >= 0.11
Matplotlib >= 1.1.1
Theano >= 0.6
Note: We have not provided links (yet) to discourage indiscriminate downloading; proceed to the platform-specific advice below to get the right answers for you.
Additionally, we strongly recommend the following optional tools:
IPython – A vastly improved Python shell; install with easy_install ipython(you may need to sudo this).
Eclipse – Graphical IDE for humans.
PyDev – Python plug-in for Eclipse that makes life much easier.
Mac OS X
First, apply the following OS Version logic:
If you have not upgraded to Mavericks (10.9), you should probably do so now.
If you cannot upgrade to Mavericks (10.9) due to some software compatibility issue (ProTools is a big one), your mileage may vary. Your best bet is to use the disk images for Python 2.7 and Numpy. Good luck.
If you have Mavericks (10.9), great! Proceed with confidence.
If you are able to use Mavericks, which comes standard with Python 2.7 and Numpy, you’re two-thirds of the way home. Installing Theano requires a few steps:
Install XCode from the AppStore
In Terminal, run
xcode-select --install. Note: Apple does not provide very informative error messages if conditions are already satisfied.
You should now be good to go; remember to back-out of the Theano directory first (cd ~ for example) before running Python.
Linux
You’ll be following Theano’s instructions closely:
apt-get install python-numpy python-scipy python-matplotlib python-dev libopenblas-dev liblapack-dev g++ python-pip
And pip (Python package manager) to get theano:
pip install theano
And that should do it!
Windows
To be honest, our experience with Windows is limited. However, we have it on reasonably good authority the Anaconda distribution should work out of the box. This distribution comes with Numpy, Theano, and IPython (among plenty other third-party libraries), and keeps itself installed in a single directory, making uninstallation as easy as removing that lone directory.
If you run into any issues (and perhaps even solve them), please contactejhumphrey@nyu.edu and we’ll work on updating this tutorial with your insight and experience.
Testing your setup.
To verify you’ve configured everything correctly, start Python in a terminal and run the following:
>>> import numpy
>>> import theano
If everything executes without complaining, then you’re all set!
Troubleshooting
If you’ve landed here, make extra sure your path variables (PATH and PYTHONPATH) are configured correctly. This should happen automatically during installation, but things may be wonky for some reason. If you are unfamiliar with manual system configuration, environment variables and the like, we refer you to these resources:
Unix Platforms
Windows
If this does not resolve your issues, it is probably due to a Theano issue. There are, generally, three things you can do at this point:
Consult the Theano website.
Search the theano-users Google group.
Try your luck at StackOverflow.
If, after this, you still cannot manage to import theano, continue to the following section.
Virtualization
In the event that you cannot / don’t want to go through the system configuration process, we additionally provide a VirtualBox disk image of a pre-configured Ubuntu machine you are free to use. All tutorial code is guaranteed to work in this environment, but it may not be as efficient as native code. However, in our experience developing this tutorial, the performance seems mostly comparable.
To use this virtual image, do the following:
Download VirtualBox.
Download our Linux System Image
Uncompress the image (tar -xzvf linux-image.tgz).
Launch VirtualBox.
Create a new machine: “Linux”, version “Ubuntu (32-bit)”.
Choose “Use existing hard disk” and select the downloaded system image (“.vdi” file extension).
Click “Start” in VirtualBox to run.
Next Steps
Congratulations! You’re now ready to dive into deep learning.
Proceed to the first example: Monophonic Instrument Classification.
Additional Resources
If you find yourself looking for more information, insight, or references at any point, we recommend the following: