1 of 31

Introduction to TensorFlow

by Aadil Hayat

2 of 31

Deep Learning

3 of 31

Deep Learning

  • Deep Learning is a new area of Machine Learning research, which has been introduced with the objective of moving Machine Learning closer to one of its original goals: Artificial Intelligence�
  • Deep Learning allows computer to build complex concepts out of simpler concepts.�
  • It is a part of broader family of Machine Learning methods based on learning representations of data.�
  • The typical example of a deep learning model is the feedforward neural network or multilayer perceptron (MLP)

4 of 31

Deep Learning

5 of 31

Deep Learning

6 of 31

Applications

  • Speech Recognition�
  • Machine Translations�
  • Natural Language Processing�
  • Object Recognition�
  • Bioinformatics

7 of 31

TensorFlow

8 of 31

What is it?

  • Open Source�
  • Numerical computation library�
  • Using Data flow graphs�
  • Flexible Architecture: CPUs, GPUs, desktop, server or mobile�
  • Available in Python, C++, Java and Go�
  • Developed by Google Brain Team for research��

9 of 31

Why Tensorflow?

Credits: Benchmarking State-of-the-Art Deep Learning Software Tools. Shi et al. Feb 2017

https://arxiv.org/pdf/1608.07249v7.pdf

10 of 31

Why Tensorflow?

  • Computational graph abstraction�
  • Faster compile time�
  • Tensorboard for visualization�
  • Data and model parallelism�
  • Embedding projector�
  • Dynamic Computation Graphs�
  • By Google :p

11 of 31

How it works?

  • For efficient numerical computing in Python most libraries do expensive operation outside Python.�
  • TensorFlow takes this a step further by defining a graph of interacting operations that run entirely outside Python.�
  • This graph of interacting operations is known as Data flow graph.��

12 of 31

Data Flow Graph

13 of 31

Data Flow Graphs

  • They describe mathematical computation with a directed graph of nodes & edges.�
  • Nodes typically implement mathematical operations or data endpoints�
  • Edges describe the input/output relationships between nodes�
  • Data edges carry dynamically-sized multi-dimensional data arrays, or tensors�

14 of 31

Basic Terminologies and Functions

  • tf.Variable:�A variable maintains state in the graph across calls to graph computation.�
  • tf.placeholder:�Inserts a placeholder for a tensor that will be fed into the graph.�
  • tf.device:�Context manager that specifies the default device to use for newly created op nodes�
  • tf.name_scope:�Context manager that installs given name as a new name scope in the default graph�
  • tf.app.flags.DEFINE_<data type>�Defines command line flags/arguments to take inputs�
  • For more details please visit Tensor Flow API

15 of 31

Data Flow Graphs Example 1

Output:�[ 30.]

16 of 31

Data Flow Graphs Example 2

Output:�Addition: [ 30.]

Subtraction: [-10.]

Multiplication: [ 200.]

Division: [ 0.5]

17 of 31

Data Flow Graphs Example 3

18 of 31

Installation

19 of 31

CPU-only Version

  • Simplest way using pip :��
  • Other ways :
    • Virtualenv
    • Docker
    • Anaconda
    • From source

https://www.tensorflow.org/install/install_linux#determine_how_to_install_tensorflow

20 of 31

GPU Version

  • Simplest way using pip :��
  • Other ways :
    • Virtualenv
    • Docker
    • Anaconda
    • From source

https://www.tensorflow.org/install/install_linux#determine_how_to_install_tensorflow

21 of 31

NVIDIA requirements for GPU support

22 of 31

MNIST Demo

23 of 31

MNIST Demo Using Softmax Regression

  • We will implement basic classification algorithm for handwriting recognition using MNIST (Modified National Institute Standards and Technology) dataset.

24 of 31

MNIST Dataset

  • The downloaded dataset is split into 3 parts:
  • Training data - 55,000 data points
  • Test data - 10,000 data points
  • Validation data - 5,000 data points

  • Each data point consist of two parts: an image and a corresponding label�
  • Image is an 28x28 matrix. We flatten it into an array of 784 length.

25 of 31

Basic Model for MNIST Problem

26 of 31

Data Flow Graph

27 of 31

Weights Visualization

28 of 31

MNIST Demo

29 of 31

Questions?

30 of 31

Important Links

31 of 31

Thanks!

Contact me:

Aadil Hayat�9616827469�hayataadil@gmail.com