0% found this document useful (0 votes)
6 views

What is TensorFlow

TensorFlow is an open-source library developed by Google for numerical computations, utilizing data flow graphs where nodes represent operations and edges represent tensors. It supports both CPU and GPU computing, making it efficient for deep learning tasks. The document outlines the fundamentals of deep learning, the structure of tensors, and provides a step-by-step guide for implementing a use case with TensorFlow.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

What is TensorFlow

TensorFlow is an open-source library developed by Google for numerical computations, utilizing data flow graphs where nodes represent operations and edges represent tensors. It supports both CPU and GPU computing, making it efficient for deep learning tasks. The document outlines the fundamentals of deep learning, the structure of tensors, and provides a step-by-step guide for implementing a use case with TensorFlow.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

What is TensorFlow?

Agenda

What is Deep Learning?

Top Deep Learning Libraries

Why TensorFlow?

What is TensorFlow?

What are Tensors?

What is a Data Flow Graph?

Program Elements in TensorFlow

Use case implementation using TensorFlow


What is Deep Learning?

Deep Learning is a subset of Machine Learning and it works on the structure and
functions of a human brain. It learns from data that is unstructured and uses complex
algorithms to train a neural net.

Input Layer Hidden Layers Output Layer


What is Deep Learning?

Deep Learning is a subset of Machine Learning and it works on the structure and
functions of a human brain. It learns from data that is unstructured and uses complex
algorithms to train a neural net.

Accepts large volumes of data


as input to build the network

Input Layer Hidden Layers Output Layer


What is Deep Learning?

Deep Learning is a subset of Machine Learning and it works on the structure and
functions of a human brain. It learns from data that is unstructured and uses complex
algorithms to train a neural net.

Processes the data by


performing complex operations
and carries out feature
extraction

Input Layer Hidden Layers Output Layer


What is Deep Learning?

Deep Learning is a subset of Machine Learning and it works on the structure and
functions of a human brain. It learns from data that is unstructured and uses complex
algorithms to train a neural net.

Generate the predicted


output by applying
suitable activation
functions

Input Layer Hidden Layers Output Layer


Top Deep Learning Libraries

• Developed by Francois Chollet • Developed by University of


• Developed by Google Brain Team
• Open source library written in Montreal
• Written in C++, Python and CUDA
Python • Written in Python

1 2 3 4 5

• Developed by Skymind • Created by Ronan Collobert,


Koray kavukcuoglu, Clement
engineering team and
Farabet
DeepLearning4J community
• Written in Python
• Written in C++ and Java
Why TensorFlow?

Provides both C++


and Python API’s
that makes it
easier to work on
Why TensorFlow?

Has a faster
Provides both C++
compilation time
and Python API’s
than other Deep
that makes it
Learning libraries
easier to work on
like keras and torch
Why TensorFlow?

Has a faster
Provides both C++
compilation time
and Python API’s
than other Deep
that makes it
Learning libraries
easier to work on
like keras and torch

TensorFlow
supports both
CPU’s and GPU’s
computing devices
What is TensorFlow?

Open source library developed by Google

Developed originally to run large numerical computations

5
Accepts data in the form of multidimensional arrays of higher dimensions
called Tensors 7

Edges 8
1

Works on the basis of Data Flow graphs that have nodes and edges

Nodes
What is TensorFlow?

Open source library developed by Google

Developed originally to run large numerical computations

5
Accepts data in the form of multidimensional arrays of higher dimensions
called Tensors 7

Edges 8
1

Works on the basis of Data Flow graphs that have nodes and edges

Nodes
What is TensorFlow?

Open source library developed by Google

Developed originally to run large numerical computations

5
Accepts data in the form of multidimensional arrays of higher dimensions
called Tensors 7

Edges 8
1

Works on the basis of Data Flow graphs that have nodes and edges

Nodes
What is TensorFlow?

Open source library developed by Google

Developed originally to run large numerical computations

5
Accepts data in the form of multidimensional arrays of higher dimensions
called Tensors 7

Edges 8
1

Works on the basis of Data Flow graphs that have nodes and edges

Nodes
What are Tensors?

Tensors

Tensor is a generalization of vectors and matrices of potentially higher dimensions. Arrays of


data with different dimensions and ranks that are fed as input to the neural network are called
Tensors.

3 5 4

2 6 7
Data in the form of 8 1 3
arrays is fed as input
to the network 2 5 9

1 4 2

Input Layer Hidden Layers Output Layer


What are Tensors?

Tensors

Tensor is a generalization of vectors and matrices of potentially higher dimensions. Arrays of


data with different dimensions and ranks that are fed as input to the neural network are called
Tensors.

Different Dimensions k Tensor of Dimensions[5]

q
What are Tensors?

Tensors

Tensor is a generalization of vectors and matrices of potentially higher dimensions. Arrays of


data with different dimensions and ranks that are fed as input to the neural network are called
Tensors.

1 3 4 7

9 7 3 2

Different Dimensions 8 4 1 6 Tensor of Dimensions[5,4]

6 3 9 1

3 1 5 9
What are Tensors?

Tensors

Tensor is a generalization of vectors and matrices of potentially higher dimensions. Arrays of


data with different dimensions and ranks that are fed as input to the neural network are called
Tensors.

Different Dimensions Tensor of


Dimensions[3,3,3]
Tensor Ranks

Tensor of Rank 0 Tensor of Rank 1

s= [200] v=[10,11,12]

Tensor of Rank 3 Tensor of Rank 2

t=[[[1],[2],[3]],[[4],[5],[6]],
[[7],[8],[9]]] m=V=[1,2,3],[4,5,6]
What is a Data Flow graph?

Each computation in TensorFlow is represented as a Data Flow Graph

Each node in the graph represents a mathematical operation (add, subtract,


multiply, etc) and each edge represents multidimensional arrays (Tensors)

Computational Graph is the graph of programming logic which Tensorflow


builds in the memory

Enables creating large scale neural networks as computing can be


distributed across several CPU’s or GPU’s

Source: TensorFlow website


Program Elements in TensorFlow

Building a
computational Step 1
graph

TensorFlow
programs
work on two
basic concept

Executing a
computational Step 2
graph
Program Elements in TensorFlow

Constants are parameters whose value does not change.


Constants To define a constant we use tf.constant() command.

Example:

a = tf.constant(2.0, tf.float32)
b = tf.constant(3.0)
Print(a, b)
Program Elements in TensorFlow

Placeholders allow us to feed data to a tensorflow model


Placeholder from outside a model. It permits a value to be assigned
later. To define a placeholder we use tf.placeholder()
command.

Example:

a = tf.placeholder(tf.float32)
b = a*2
with tf.Session() as sess: feed_dict specifies tensors
result = sess.run(b,feed_dict={a:3.0})
that provide concrete
print result values to the placeholders
Program Elements in TensorFlow

Variables allow us to add new trainable parameters to


Variable graph. To define a variable we use tf.Variable() command
and initialize them before running the graph in a session.

Example:

W = tf.Variable([.3],dtype=tf.float32)
b = tf.Variable([-.3],dtype=tf.float32)
x = tf.Placeholder(tf.float32)
linear_model = W*x+b
Program Elements in TensorFlow

A session is run to evaluate the nodes. This is called as the


Session TensorFlow runtime.

Example:

a = tf.constant(5.0) 5.0
Multiplication
b = tf.constant(3.0) 15.0
c = a*b
# Launch Session
sess = tf.Session() 3.0
# Evaluate the tensor c
print(sess.run(c))

Running a Computation
Graph
TensorFlow program basics

HelloWorld using TensorFlow


TensorFlow program basics

Performing Computations using TensorFlow


TensorFlow program basics

Matrix Multiplication using TensorFlow


TensorFlow program basics

Variables in TensorFlow
TensorFlow program basics

Placeholders in TensorFlow
TensorFlow program basics

TensorFlow Graphs
Use case Implementation using TensorFlow
Lets use various features of an individual to predict what class of income they belong to (>50k or <=50k)
using a Census Data.

age martial_status gender

native_country
workclass occupation capital_gain

income_bracket
education relationship capital_loss

Predict Income
race hours_per_week
education_num
Use case Implementation using TensorFlow
1. Read the census_data.csv using pandas library

2. Display the head of the dataset


Use case Implementation using TensorFlow
3. Convert the Label column to 0s and 1s instead of strings

4. Perform a Train Test split on the data


Use case Implementation using TensorFlow
5. Create the feature columns for the categorical values using vocabulary lists or hash buckets

6. Create the feature columns for the continuous values using numeric_column
Use case Implementation using TensorFlow
7. Put all these variables into a single list with the variable name feat_cols

8. Create the input function. Batch size it up to you

9. Create the Model with tf.estimator using LinearClassifier


Use case Implementation using TensorFlow
10. Train the model for at least 5000 steps

11. Evaluation of the model


Use case Implementation using TensorFlow
12. Create a list of class_ids key values from the prediction list of dictionaries. These predictions will
be used to compare against y_test values

13. Calculate models performance on Test data

You might also like