Introduction to TensorFlow Machine Learning Library

What is TensorFlow?

TensorFlow is an open source software library for numerical computation using data flow graphs, a type of graph that represents data dependencies between various operations. You can see the source code here Nodes in the data flow graph represent mathematical operations to be run over the dataset, while the graph edges represent the multidimensional data arrays (tensors) that flow between them. TensorFlow's flexible architecture enables you to deploy computation to one or more CPUs or GPUs on a desktop, server, or mobile device without rewriting code.

The fact that TensorFlow provides the option to use the CPU and/or the GPU means that the computational speed can be increased by orders of magnitude. This is extremely useful as the datasize increases and/or the mathematical operations applied becomes more complex and time consuming.

TensorFlow is currently used by a number of google products, both research and production, such as speech recognition, Gmail and search to name just a few. 


Python was the first client language supported by TensorFlow so we will install it using PIP. However, there are APIs available to use TensorFlow in other languages. You can read more about it here

All the installation instructions are here You can use virtualenv, docker, or install natively on your computer using either CPU and GPU or CPU only. In this tutorial we will intall it natively and only use the option of using the CPU (as only particular GPUs are able to run TensorFlow).

To install TensorFlow via PIP run the following command:

# Python 2
pip install tensorflow
# Python 3
pip3 install tensorflow

Thats it, if you have any errors try the following commands:

sudo pip  install --upgrade TF_BINARY_URL   # Python 2.7
sudo pip3 install --upgrade TF_BINARY_URL   # Python 3.N

Installation Validation

Open a python shell in your terminal and enter the following commands:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
# Hello, TensorFlow!

You have now validated that TensorFlow is installed on your machine.

Subscribe to our mailing list

* indicates required