Tensorflow is an open source software library for numerical computation using data flow graphs. It was originally developed by researchers and engineers working on the Google Brain Team within Google’s Machine Intelligence research organization for the purposes of conducting machine learning and deep neural networks research, but the system is general enough to be applicable in a wide variety of other domains as well.
How to Install Tensorflow
Installation for tensorflow is really easy. Based on my experience of installation on my mac, it is far easier than Caffe which is another deep learning framework.
Environment
This tutorial is based on:
- Mac OSX 10.12.1
- python 3.6.0
- Tensorflow 1.0 release
Installation of Python Virtual Environment
Python usually has a lot of different versions which is always a headache for beginners, especially you have projects with different dependencies of various versions of python.
To solve this problem, I recommend you use python version manager such as virtualenv, pyenv and conda.
In this tutorial, I use conda as an example.
You can refer to this link for more information: Help Docs for Conda
install Anaconda, download it from: Downloads of Anaconda. And install it follow the instructions of this website. This is an GUI version which is more user-friendly.
Open your terminal and test if you can use conda:
1 | $ conda -V |
- create a new virtual environment for Tensorflow
1 | $ conda create -name <yourenvname> python=3.6 |
- switch to virtual environment you just created
1 | $ source activate <yourenvname> |
Here you have created a new virtual envronment ready for installation of Tensorflow. And you will find the name of python env appears at the beginning of your command line:
1 | (<yourenvname>) $ # your command |
Installation of Tensorflow
- Then you can install tensorflow in your virtual environment with just one command! Suppose the name of this environment is:
tensorlfow
1 | (tensorlfow) $ conda install tensorflow |
- You are all set! You can run python script in your command line to test whether it will work, but I recommend to use spider mentioned in the next section.
Note: If you want to exit your virtual environment, you can simply type source deactivate in your terminal.
Test Your Tensorflow
- Open your anaconda, then you will find your virtualenv here:

choose tensorflow (you should choose your virtual environment you just created) and then install “spyder” in the panel.
- Lauch spyder and try to run the script below:
1 | ''' |
- If you can get the result of this linear regression then you are done!
Have fun with it!