# Setting up TensorFlow.

May 17th, 2018: A guide to the installation of the prerequisites for, and tensorflow itself.

## Preface.

I use Windows 10 64-bit, and I will assume your system is the same. Typically, when installing libraries, there will be separate versions for the various major operating systems. Make sure you select the appropriate versions when given the choice. This guide is somewhat of a prerequisite for the TensorFlow posts I will make in the future.

## Python.

I am using Python 3.6.5 **64-bit** for Windows. As of May 2018, this is available for download here. I installed this for all users (in the C:// drive), with all optional components. Make certain you have added <...some_path...>/Python36 and <...some_path...>/Python36/Scripts to your PATH environment variable. Try running the following command.

`name@computer:~$ python -V`

`Python 3.6.5`

If you see anything other than the version of python displayed, then your installation went wrong.

`name@computer:~$ pip -V`

`pip 10.0.1 ...`

The version of pip is less important, but ensure this command does not fail to print SOME version.

## NumPy.

NumPy is an optimized linear algebra library for Python, written in C. This library is the backbone for all other computational libraries we will install. You can install NumPy using from the pip package using the following command.

`name@computer:~$ pip install numpy`

`...`

You should receive come confirmation message that NumPy has installed correctly in the terminal. Make sure your installation is correct by running the following commands in the terminal.

`name@computer:~$ python`

`>>> import numpy as np`

`>>> a = np.array([[1.0], [2.0]])`

`>>> b = np.array([[3.0], [4.0]])`

`>>> print(a.dot(b.T))`

`[[3. 4.]`

` [6. 8.]]`

`>>> print(a.T.dot(b))`

`[[11.]]`

The variables a and b are column vectors. The first dot operation performs an outer product between the vectors . The second dot operation performs an inner product, which is commonly called a dot product.

## MatPlotLib.

MatPlotLib is a graphics library for generating charts and plots for calculations from NumPy. This library is essential for all modern researchers, for analyzing performance during experiments, and many other creative applications (even animations). Install this with the following command.

`name@computer:~$ pip install matplotlib`

`...`

Much like the previous library, you should receive a conformation message printed to the terminal that MatPlotLib has installed successfully. Note that other dependencies may be installed while this command executes. Make sure your installation is correct by executing the following command to the terminal.

`name@computer:~$ python`

`>>> import numpy as np`

`>>> import matplotlib.pyplot as plt`

`>>> x = (np.arange(100) - 50) / 10`

`>>> y = np.sin(x * x)`

`>>> plt.plot(x, y, "g-")`

`>>> plt.xlabel("x")`

`>>> plt.ylabel("y(x) = sin(x * x)")`

`>>> plt.title("Cool Plot!")`

`>>> plt.grid(True)`

`>>> plt.show()`

You should see the following PNG displayed to your screen. If the graph is empty, or an error message is displayed, then your installation has went wrong. Note how MatPlotLib is typically used with data from NumPy.

## Jupyter Notebook.

Jupyter Notebook is my favorite tool for prototyping. Though not entirely necessary, I suggest installing this package and familiarizing yourself with it. I use this tool in my research in conjunction with MatPlotLib for collecting and plotting data, and showcasing in a simplified view. Install IPython and Jupyter Notebook the following commands.

`name@computer:~$ pip install ipython`

`...`

IPython is somewhat of the engine for Jupyter, and is necessary for Jupyter Notebook to function. Again, confirm that you have received some installation success message in your terminal.

`name@computer:~$ pip install jupyter`

`...`

This command installs the Jupyter Notebook and all other dependencies. After the installation is successful, you can start the Jupyter Runtime from your terminal using the following command.

`name@computer:~$ jupyter notebook`

If all goes well, your web browser will connect to a free localhost port, where the Jupyter server is running. From this interface, you can create a Python 3 notebook, or even open a terminal from within Jupyter.

## TensorFlow.

WHEW, with all that installed, we can turn our attention to the MVP of this post, TensorFlow. Developed by Google, this library wraps provides accelerated linear algebra operations and automatic differentiation, targeting developers of Neural Networks. TensorFlow is my favorite numerical library, and is handy for small and large experiments.

I expect your TensorFlow installation to support Eager Execution, and I recommend version 1.8.0 (the latest as of May, 2018). Like the previous packages, our lives are made easy by pip. Run the following in your terminal. Note we are installing the CPU version of TensorFlow. If you have a supported GPU, check out these instructions.

`name@computer:~$ pip install tensorflow`

`...`

If you encounter any suspicious messages, I recommend checking the common problems section for your operating system. TensorFlow relies on specific versions of Python (3.5.X and 3.6.X as of May, 2018). With everything configured, run the following test in your terminal, and cross your fingers.

`name@computer:~$ python`

`>>> import tensorflow as tf`

`>>> hello = tf.constant('TensorFlow is Cool!')`

`>>> sess = tf.Session()`

`>>> print(sess.run(hello))`

`...`

`TensorFlow is Cool!`

There may be some initialization messages before you see your message printed. Check the TensorFlow docs to find out what these messages describe in more depth. Congrats, your system is now fully configured!