【轉載】Deep Learning Python Tutorial

Overview

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.php


 

Contents


 

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
html

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:python


 

Setting up Your System

The provided source code has the following dependencies, which must be installed and configured:linux

  1. Python 2.7
  2. Numpy >= 1.8
  3. Scipy >= 0.11
  4. Matplotlib >= 1.1.1
  5. 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.git

Additionally, we strongly recommend the following optional tools:github

  1. IPython – A vastly improved Python shell; install with easy_install ipython(you may need to sudo this).
  2. Eclipse – Graphical IDE for humans.
  3. PyDev – Python plug-in for Eclipse that makes life much easier.

 

Mac OS X

First, apply the following OS Version logic:web

  • 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:shell

  1. Install XCode from the AppStore
  2. In Terminal, run
    1. xcode-select --installNote: Apple does not provide very informative error messages if conditions are already satisfied.
    2. Download Theano (git clone git://github.com/Theano/Theano.git)
    3. cd Theano
    4. python setup.py build
    5. python setup.py install

You should now be good to go; remember to back-out of the Theano directory first (cd ~ for example) before running Python.macos

 

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

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:

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:

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:

  1. Download VirtualBox.
  2. Download our Linux System Image
  3. Uncompress the image (tar -xzvf linux-image.tgz).
  4. Launch VirtualBox.
  5. Create a new machine: 「Linux」, version 「Ubuntu (32-bit)」.
  6. Choose 「Use existing hard disk」 and select the downloaded system image (「.vdi」 file extension).
  7. 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:

    • Theano Deep Learning Tutorials (Python): link
    • Stanford Deep Learning Tutorial (Matlab): link
相關文章
相關標籤/搜索