Using Anaconda for Deep Learning

Hi guys!

I am a Deep Learning graduate from Udacity and I have built variety of projects ranging from bike estimation for a shop to using sequence to sequence model for language translation. This is my first tutorial on Deep Learning and will continue writing blogs on a weekly basis on the stuff I learn over time in this field. Hope you guys like it.

In the first tutorial we are going to install Anaconda which is actually a distribution of software that comes with conda, Python, and over 150 scientific packages and their dependencies. It consists of over 150+ packages, basically consisting of all the important data science libraries needed in python. ‘conda’ is basically a package and environment manager which helps in installing libraries and creating virtual environments which we will talk in a bit.

Installing Anaconda

Install Anaconda from the official site which tells how to install it on Windows/Linux system. Follow the guidelines and then move to the next part.

Creating Virtual Environments

On installing Anaconda properly you should see that on typing ‘conda’ in command line, it should get recognized instead of throwing an error.

The great part about using Anaconda is the ability to work in virtual environments. The purpose of creating virtual environments is to ensure in future we don’t run into a version issue for a installed library which occurs quite often. We create an environment like this:

conda create -n env_name list_of_packages

For example:

conda create -n py3 python3 numpy

The above command will create a ‘py3’ environment having python3 and numpy packages installed.

We can use ‘conda list’ command to list the packages installed in a particular environment.

Navigating to a particular environment

Let’s say we create an environment ‘py3’ and we want to move to that particular virtual environment. This is done as follows:

conda create -n py3 numpy python3
source activate py3 (activates py3 virtual env)
source deactivate (deactivates py3 virtual env)

Installing packages

For installing packages we use the following command:

conda install package_name

For installing multiple packages we simply list them a space after another as follows:

conda install package_name1 package_name2

We can also specify version if we are interested in installing a particular version library as follows:

conda install package_name1=version1 package_name2=version2

Upgrading packages

For upgrading packages we use the following command:

conda upgrade — all (upgrades all packages)
conda upgrade package_name (upgrades a specific package)

Listing packages

For listing packages we can use the following command which lists the packages currently installed:

conda list

Best Practices

By default conda creates a virtual environment for us where we can install and upgrade the required libraries need for our project. However its better to work in two environments one for python3 and the other python2 and install the required libraries in each virtual env for project our work.

In the next tutorial we will talk about Jupyter Notebooks which is where we will basically start writing python code for our Deep Neural Nets and build amazing stuff.

Hope you guys liked it. Happy learning!