Express Deep Learning in Python - Part 0

This notebook explains how to install all the preriquistes and libraries that you will need to run the following tutorials. If you can execute all the following cells, you are good to go.

Environment configuration

There are two major package managers in Python: pip and conda. For this tutorial we will be using conda which, besides being a package manager is also useful as a version manager. There are two main ways to install conda: Anaconda and Miniconda.

In order to install tensorflow we recommend following the official documentation. In particular, for the conda installation, they advise to use pip instead of conda as the only available Anaconda package for tensorflow is not actively mantained.

All the available tensorflow versions (for both Python 2 and 3 and with CPU and GPU support) can be found in this link. For this course we will be using: https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp35-cp35m-linux_x86_64.whl

The commands to setup the environment are the following

$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh
$ conda create --name keras python=3.5
$ source activate keras
(keras) $ conda install numpy scipy jupyter nb_conda
(keras) $ export tfBinaryURL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp35-cp35m-linux_x86_64.whl
(keras) $ pip install $tfBinaryURL
(keras) $ conda install -c conda-forge keras
(keras) $ jupyter notebook

In the previous code, replace $tfBinaryURL with the version of tensorflow to use.

Now you check if keras was succesfully installed.


In [1]:
import keras

print(keras.__version__)


Using TensorFlow backend.
2.0.6

Troubleshooting

If the above says "using backend theano" and fails, run as:

KERAS_BACKEND=tensorflow jupyter notebook

Optional libraries

These are some optional libraries to download in order to see some visualizations. They take a while, so if you don't have good Internet connection or no time you can skip them.

(keras) $ conda install -c conda-forge pydotplus
(keras) $ conda install graphviz
(keras) $ conda install scikit-learn
(keras) $ conda install seaborn

Pre-download the dataset

The dataset we will use (MNIST) will be downloaded by Keras automatically the first time you use it. To save time, you can download it now running the next cell.


In [2]:
from keras.datasets import mnist
mnist.load_data();

Tensorboard

Tensorboard should be installed with TensorFlow. In order to check if it works, open a console and run

$ which tensorboard

The ouput should be an executable file inside your anaconda environment. Something like ~/anaconda2/envs/keras/bin/tensorboard


Those are all the requirements you need. Now you are ready to go to tutorial number 1!