Code in Python
Machine Learning and Deep Learning Blogs

Understanding TensorFlow for noobs

Deep Learning is a trending field in Computer Science. It is a subset of Machine Learning and Artificial Intelligence. Tensorflow is an open source Machine Learning Library developed by Google that supports neural networks and other Deep learning models. In this tutorial series, we will learn more about Tensorflow and construct deep learning models on our own. To get started with Tensorflow it is recommended to have some basic knowledge of Python. You can refer these tutorials to revisit some crucial Python concepts.

1) Variables in Python
2) Functions in Python
3) Classes in Python

Some elementary knowledge of scalars, vectors, matrices, and graphs is recommended to fully understand the working of Tensorflow. Briefly, I would say, scalars are quantities that have magnitude (just the numbers) and no direction. For example, 5 kilograms, 25 degrees, etc. Vectors are quantities that have both magnitude and direction. For example, 5 m to the north, 45 degrees south, etc. Matrices are an array of numbers in 2D space. Now there is a third quantity called tensor. Tensor is a mathematical representation of a physical quantity that has magnitude and many directions. Tensor is an array of numbers or functions that transform according to certain rules. You can represent tensor as an array of N^R numbers in N-dimensional space, where R is the rank of the tensor. To visualize better we will take N = 3 so as to remain in 3-D space. You can think scalars, vectors, and matrix as a special case of a tensor. Since the rank of a tensor object gives the number of dimensions. Scalar is a rank zero tensor (R = 0), vector is a rank one tensor (R = 1) and matrix (2D array) is rank two tensor (R = 2). To read more on Tensor read this article

Google’s TensorFlow, as the name indicates, is a framework to define and run computations involving tensors. Internally TensorFlow represents tensor as an N-dimensional array of base datatypes. Your goal very basic is to manipulate and pass around Tensorflow class tf.Tensor object. A tf.Tensor has the following properties:

  1. a data type (float32, int32, or string, for example)
  2. a shape

Some special types that we will cover in upcoming blog posts are:

  1. tf.Variable
  2. tf.Constant
  3. tf.Placeholder
  4. tf.SparseTensor

To learn more on TensorFlow’s tensor read this

One thing that is impressive about Tensorflow is it leverages the power of parallel computing by using data flow graphs and threading. You can learn how TensorFlow uses Dataflow graphs and what is it advantages from this link

To know more on Tensorflow’s multithreading and queues read this

In layman terms this how tensorflow’s computational graph architecture works. A node is an independently executing block of code which depends on resources propagated by all its parents. If those resources are not available, then it waits until all resources from all parents are computed and made available. The main idea behind computational graphs is that computations don’t always need to happen in order. There are some computations that can happen side-by-side. There are some computations that depend on other computations. Instead of sequentially processing everything, we try to run as much in parallel as possible.
computational graph tf

Installing Tensorflow

The most simple and direct method to install tensorflow is to use this command

pip install tensorflow

Using Conda

We’ll be using Conda to install TensorFlow.

OS X or Linux

Run the following commands to setup your environment:
conda create -n tensorflow python=3.5
source activate tensorflow
conda install pandas matplotlib jupyter notebook scipy scikit-learn
pip install tensorflow


And installing on Windows. In your console or Anaconda shell,
conda create -n tensorflow python=3.5
activate tensorflow
conda install pandas matplotlib jupyter notebook scipy scikit-learn
pip install tensorflow

I have this article has given you a brief insight on working with TensorFlow. If you like this article then share it with your friends. Subscribe to my Python and Machine Learning Blog newsletter for updates.

Akarsh Singh
Follow me

Akarsh Singh

Founder, Code in Python. Web and Android App Developer. He loves Python and wants to share his knowledge via this website. Follow him on Facebook, Twitter and Github.
Akarsh Singh
Follow me

Latest posts by Akarsh Singh (see all)


  1. It’s awesome to pay a visit this website and reading the views of all friends concerning this article, while I am also
    zealous of getting experience.

  2. I have recently started a blog, the information you offer on this website has helped me greatly. Thank you for all of your time & work. “Never trust anybody who says ‘trust me.’ Except just this once, of course. – from Steel Beach” by John Varley.

Leave a Reply

Your email address will not be published.


© 2019 Code in Python