Setup Machine Learning Environment

Setup on macOS 10.12.5 — Following Goal. Setup Keras with tensorflow or cntk backend for machine learning (includes deep learning). (I decided to be based on Python 2.7)

Step 1: Download Anaconda Command Line Installer and run it as follows. Go through the wizards steps, afterwards check the installation i.e.

$ bash Anaconda2–
$ which python
akmac2:~ ak$ python
Python 2.7.13 |Anaconda 4.4.0 (x86_64)| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: and
>>> exit()

Create a workspace directory where you want to store your project files

$ mkdir $HOME/Workspace/deeplearning
$ cd $HOME/Workspace/deeplearning

Step 2: Install Tensorflow inside an anaconda environment

$ conda create -n keras
Fetching package metadata .........
Solving package specifications:
Package plan for installation in environment /Users/ak/Applications/anaconda2/envs/keras
$ source activate keras
(keras) deeplearning $ pip install --ignore-installed --upgrade
(keras) deeplearning $

Hint: To leave the conda environment just use: source deactivate keras.

Step 3: Test tensorflow installation

# Deactivated Warnings
(keras) deeplearning $ vi
import os
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
(keras) deeplearning $ python
Hello, TensorFlow!

Hint: Setting TF_CPP_MIN_LOG_LEVEL to 2 disables warnings.

Step 4: Install Keras and test keras installation

(keras) deeplearning $ pip install keras
Successfully installed keras-2.0.6 theano-0.9.0
(keras) deeplearning $ curl -O
(keras) deeplearning $ python
Test loss: 0.0875640926854 (3 epochs)
Test accuracy: 0.9747 (3 epochs)

Disclaimer: A MacBook might not be the best device for machine learning. I hope it will be sufficient to get hands on some practical use cases for object detection. Stay tuned for more details.