Python Setup for Stockholm Natural Language Processing Meetup, Deep Learning Workshop

(install instructions borrowed from https://github.com/vkaynig/ComputeFest2015_DeepLearning)

Let's make the second part of this workshop as interactive and exciting as possible. To make this possible, it is important that you make sure all the neccessary libraries are up and running on your laptop.

We will be using Python 2.7 with Ipython notebooks, as well as Theano. You should also have a basic understanding of git and how to clone a repository. You should be reasonably comfortable with operating on the command line of your chosen OS, as well.

This document is meant to provide some pointers on how to install these libraries. Feel free to alter the environment to your preferred setup.

Installation should be pretty straight forward for Mac or Linux users. If you are using Windows, don't despair, I am using it myself and there are some tips below that hopefully will enable you to make it work.

You can download this notebook here, or by clicking on the download symbol in the upper right corner if you are viewing this in the nbviewer.

Basic Python installation

  • We are using Python 2.7

  • If you don't have Python installed yet, you can use a distribution like Enthought Canopy (previously EPD) . Note that this distribution is only free if you are affiliated with a university.

  • Anaconda is another Python distribution that is generally free, but under Windows I had problems getting theano to work with this distribution.

  • If you are using Windows, and you don't have access to Enthought or it is not working for you, see below on to help you install the environment from scratch.

  • Similarly, if you are using OSX and aren't already set up with a recent version of python, see below.

Installing Python under Windows 8 from scratch

  • We don't recommend using virtual environments for Windows (unless you are an expert).

  • Install the 2.7 32-bit version of Python from python.org.

  • Install MinGW following these instructions.

  • Put the path to MingW into your path environment variable. You can access the variable by hitting win+S and searching for 'environment'. Then choose the path variable for your account and add ';C:\MinGW\bin' to the end.

  • Use the pre-compiled packages provided by Christoph Gohlke to install 'numpy-mkl', 'scipy', 'theano', and 'pip'.

Installing Python under OSX

  • We strongly suggest using homebrew.
  • Make sure /usr/local/bin is on your path.
  • Install the latest python
      brew install python
  • Make sure you see the correct python
      which python
    should report /usr/local/bin/python
  • Install virtualenv
      pip install virtualenv
  • Create and activate a new virtual environment
      virtualenv DeepLearningWorkshop
      source DeepLearningWorkshop/bin/activate
    `

Installing Ipython

For the workshop we will be using Ipython notebooks. You can install the necessary packages with 'pip'.

  • IPython installation instructions

  • You can test if the setup works by executing 'ipython notebook' on the command line. This should open a browser window showing an option to create a new ipython notebook.

  • At this point you can also download this IPython notebook and execute it yourself. You will need to do this at the end to see if you can execute the script that tests your setup.

Getting friendly with git

The installation of Theano involves very basic git commands. If you don't care about the specifics you most probably will be able to finish the installation by just copy and pasting the commands from the Theano installation documentation. If you would like to get some more input on what you are doing, here are some useful resources:

  • First of all, it does not hurt to just google git tutorial and have a look at some of the pages.
  • There is a nice interactive tutorial from Github.
  • And here is a git cheat-sheet in case you need a quick reference.

Installing Theano

Theano is a great library for deep learning, even providing transparent execution of your code on the GPU (though only on NVIDIA GPUs). The developers did a great job not only with the library itself, but also with the documentation.

For the workshop you should have a working installation of Theano on the CPU, GPU processing is optional and will make computations much faster, but might be not suitable for your laptop configuration.

Checking if everything works

If you have installed everything needed for the workshop successfully you should be able to import theano without problems:


In [3]:
from theano import *
import theano.tensor as T