SlideShare a Scribd company logo
Agenda
▪ Difference Between Machine Learning and Deep Learning
▪ What is Deep Learning?
▪ What is TensorFlow?
▪ TensorFlow Data Structures
▪ TensorFlow Use-Case
Agenda
▪ Difference Between Machine Learning and Deep Learning
▪ What is Deep Learning?
▪ What is TensorFlow?
▪ TensorFlow Data Structures
▪ TensorFlow Use-Case
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Machine Learning vs Deep Learning
Let’s see what are the differences between Machine Learning and Deep Learning
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Machine Learning vs Deep Learning
Machine Learning Deep Learning
High performance on less data Low performance on less data
Deep Learning Performance
Machine Learning Performance
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Machine Learning vs Deep Learning
Machine Learning Deep Learning
Can work on low end machines Requires high end machines
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Machine Learning vs Deep Learning
Machine Learning Deep Learning
Features need to be hand-coded
as per the domain and data type
Tries to learn high-level features
from data
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What is Deep Learning?
Now is the time to understand what exactly is Deep Learning?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What is Deep Learning?
Input Layer
Hidden Layer 1
Hidden Layer 2
Output Layer
A collection of statistical machine learning techniques used to learn feature hierarchies often based on
artificial neural networks
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What are Tensors?
Let’s see what are Tensors?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What Are Tensors?
 Tensors are the standard way of representing data in TensorFlow (deep learning).
 Tensors are multidimensional arrays, an extension of two-dimensional tables (matrices) to data
with higher dimension.
Tensor of
dimension[1]
Tensor of
dimensions[2]
Tensor of
dimensions[3]
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Tensors Rank
Rank Math Entity Python Example
0 Scalar (magnitude
only)
s = 483
1 Vector (magnitude
and direction)
v = [1.1, 2.2, 3.3]
2 Matrix (table of
numbers)
m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
3 3-Tensor (cube of
numbers)
t =
[[[2], [4], [6]], [[8], [10], [12]], [[14], [16], [18
]]]
n n-Tensor (you get
the idea)
....
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Tensor Data Types
In addition to dimensionality Tensors have different data types as well, you can assign any one of
these data types to a Tensor
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What Is TensorFlow?
Now, is the time explore TensorFlow.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What Is TensorFlow?
 TensorFlow is a Python library used to implement deep networks.
 In TensorFlow, computation is approached as a dataflow graph.
3.2 -1.4 5.1 …
-1.0 -2 2.4 …
… … … …
… … … …
Tensor Flow
Matmul
W X
Add
Relu
B
Computational
Graph
Functions
Tensors
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
TensorFlow Code-Basics
Let’s understand the fundamentals of TensorFlow
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
TensorFlow Code-Basics
TensorFlow core programs consists of two discrete sections:
Building a computational graph Running a computational graph
A computational graph is a series of TensorFlow
operations arranged into a graph of nodes
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
TensorFlow Building And Running A Graph
Building a computational graph Running a computational graph
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
print(node1, node2)
Constant nodes
sess = tf.Session()
print(sess.run([node1, node2]))
To actually evaluate the nodes, we must run
the computational graph within a session.
As the session encapsulates the control and
state of the TensorFlow runtime.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Tensorflow Example
a
5.0
Constimport tensorflow as tf
# Build a graph
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# Launch the graph in a session
sess = tf.Session()
# Evaluate the tensor 'C'
print(sess.run(c))
Computational Graph
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Tensorflow Example
a
b
5.0
6.0
Const
Constimport tensorflow as tf
# Build a graph
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# Launch the graph in a session
sess = tf.Session()
# Evaluate the tensor 'C'
print(sess.run(c))
Computational Graph
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Tensorflow Example
a
b c
5.0
6.0
Const Mul
Constimport tensorflow as tf
# Build a graph
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# Launch the graph in a session
sess = tf.Session()
# Evaluate the tensor 'C'
print(sess.run(c))
Computational Graph
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Tensorflow Example
a
b c
5.0
6.0
Const Mul
30.0
Constimport tensorflow as tf
# Build a graph
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b
# Launch the graph in a session
sess = tf.Session()
# Evaluate the tensor 'C'
print(sess.run(c))
Running The Computational Graph
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Graph Visualization
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Graph Visualization
 For visualizing TensorFlow graphs, we use TensorBoard.
 The first argument when creating the FileWriter is an output directory name, which will be created
if it doesn't exist.
File_writer = tf.summary.FileWriter('log_simple_graph', sess.graph)
TensorBoard runs as a local web app, on port 6006. (this
is default port, “6006” is “ ” upside-down.)oo
tensorboard --logdir = “path_to_the_graph”
Execute this command in the cmd
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Constants, Placeholders and Variables
Let’s understand what are constants, placeholders and variables
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Constant
One type of a node is a constant. It takes no inputs, and it outputs a value
it stores internally.
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
print(node1, node2)
Constant nodes
Constant
Placeholder
Variable
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Constant
One type of a node is a constant. It takes no inputs, and it outputs a value
it stores internally.
import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
print(node1, node2)
Constant nodes
Constant
Placeholder
Variable
What if I want the
graph to accept
external inputs?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Placeholder
Constant
Placeholder
Variable
A graph can be parameterized to accept external inputs, known as placeholders.
A placeholder is a promise to provide a value later.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Placeholder
Constant
Placeholder
Variable
A graph can be parameterized to accept external inputs, known as placeholders.
A placeholder is a promise to provide a value later.
How to modify the
graph, if I want new
output for the same
input ?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Variable
Constant
Placeholder
Variable
To make the model trainable, we need to be able to modify the graph to get
new outputs with the same input. Variables allow us to add trainable
parameters to a graph
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Let Us Now Create A Model
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Simple Linear Model
import tensorflow as tf
W = tf.Variable([.3], tf.float32)
b = tf.Variable([-.3], tf.float32)
x = tf.placeholder(tf.float32)
linear_model = W * x + b
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
print(sess.run(linear_model, {x:[1,2,3,4]}))
We've created a model, but we
don't know how good it is yet
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
How To Increase The Efficiency Of The Model?
Calculate the loss
Model
Update the Variables
Repeat the process until the loss becomes very small
A loss function measures how
far apart the current model is
from the provided data.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Calculating The Loss
In order to understand how good the Model is, we should know the loss/error.
To evaluate the model on training data, we need a y i.e. a
placeholder to provide the desired values, and we need to
write a loss function.
We'll use a standard loss model for linear regression.
(linear_model – y ) creates a vector where each element is
the corresponding example's error delta.
tf.square is used to square that error.
tf.reduce_sum is used to sum all the squared error.
y = tf.placeholder(tf.float32)
squared_deltas = tf.square(linear_model - y)
loss = tf.reduce_sum(squared_deltas)
print(sess.run(loss, {x:[1,2,3,4], y:[0,-1,-2,-3]}))
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Reducing The Loss
Optimizer modifies each variable according to the magnitude of the derivative of loss with
respect to that variable. Here we will use Gradient Descent Optimizer
How Gradient Descent Actually
Works?
Let’s understand this
with an analogy
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Reducing The Loss
• Suppose you are at the top of a mountain, and you have to reach a lake which is at the lowest
point of the mountain (a.k.a valley).
• A twist is that you are blindfolded and you have zero visibility to see where you are headed. So,
what approach will you take to reach the lake?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Reducing The Loss
• The best way is to check the ground near you and observe where the land tends to descend.
• This will give an idea in what direction you should take your first step. If you follow the
descending path, it is very likely you would reach the lake.
Consider the length of the step as learning rate
Consider the position of the hiker as weight
Consider the process of climbing down
the mountain as cost function/loss
function
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Reducing The Loss
Global Cost/Loss
Minimum
Jmin(w)
J(w)
Let us
understand the
math behind
Gradient
Descent
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Batch Gradient Descent
The weights are updated
incrementally after each
epoch. The cost function J(⋅),
the sum of squared errors
(SSE), can be written as:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Batch Gradient Descent
The weights are updated
incrementally after each
epoch. The cost function J(⋅),
the sum of squared errors
(SSE), can be written as:
The magnitude and direction
of the weight update is
computed by taking a step in
the opposite direction of the
cost gradient
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Batch Gradient Descent
The weights are updated
incrementally after each
epoch. The cost function J(⋅),
the sum of squared errors
(SSE), can be written as:
The magnitude and direction
of the weight update is
computed by taking a step in
the opposite direction of the
cost gradient
The weights are then updated
after each epoch via the
following update rule:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Batch Gradient Descent
The weights are updated
incrementally after each
epoch. The cost function J(⋅),
the sum of squared errors
(SSE), can be written as:
The magnitude and direction
of the weight update is
computed by taking a step in
the opposite direction of the
cost gradient
The weights are then updated
after each epoch via the
following update rule:
Here, Δw is a vector that
contains the weight
updates of each weight
coefficient w, which are
computed as follows:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Reducing The Loss
Suppose, we want to find the best parameters (W) for our learning algorithm. We can apply the
same analogy and find the best possible values for that parameter. Consider the example below:
optimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)
sess.run(init)
for i in range(1000):
sess.run(train, {x:[1,2,3,4], y:[0,-1,-2,-3]})
print(sess.run([W, b]))
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
TensorFlow Use-Case
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Long Short Term Memory Networks Use-Case
We will feed a LSTM with correct sequences from the text of 3 symbols as inputs and 1 labeled
symbol, eventually the neural network will learn to predict the next symbol correctly
had a general
LSTM
cell
Council
Prediction
label
vs
inputs
LSTM cell with
three inputs and
1 output.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Long Short Term Memory Networks Use-Case
long ago , the mice had a general council to consider what measures
they could take to outwit their common enemy , the cat . some said
this , and some said that but at last a young mouse got up and said he
had a proposal to make , which he thought would meet the case . you
will all agree , said he , that our chief danger consists in the sly and
treacherous manner in which the enemy approaches us . now , if we
could receive some signal of her approach , we could easily escape from
her . i venture , therefore , to propose that a small bell be procured , and
attached by a ribbon round the neck of the cat . by this means we
should always know when she was about , and could easily retire while
she was in the neighborhood . this proposal met with general applause ,
until an old mouse got up and said that is all very well , but who is to
bell the cat ? the mice looked at one another and nobody spoke . then
the old mouse said it is easy to propose impossible remedies .
How to
train the
network?
A short story from Aesop’s Fables
with 112 unique symbols
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Long Short Term Memory Networks Use-Case
A unique integer value is assigned to each symbol because
LSTM inputs can only understand real numbers.
20 6 33
LSTM
cell
LSTM cell with
three inputs and
1 output.
had a general
.01 .02 .6 .00
37
37
vs
Council
Council
112-element
vector
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Session In A Minute
Machine Learning vs Deep Learning What is Deep Learning? What is TensorFlow?
TensorFlow Code-Basics Simple Linear Model TensorFlow Use-Case
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tutorial | Edureka

More Related Content

What's hot (20)

PDF
MLflow Model Serving
Databricks
 
PPTX
Introducing MlFlow: An Open Source Platform for the Machine Learning Lifecycl...
DataWorks Summit
 
PPTX
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...
Simplilearn
 
PDF
Graphql
Niv Ben David
 
PDF
Apache Kafka Architecture & Fundamentals Explained
confluent
 
PDF
"Managing the Complete Machine Learning Lifecycle with MLflow"
Databricks
 
PDF
REST vs GraphQL
Squareboat
 
PDF
Kubeflow Pipelines (with Tekton)
Animesh Singh
 
PDF
Use MLflow to manage and deploy Machine Learning model on Spark
Herman Wu
 
PDF
MLOps with Kubeflow
Saurabh Kaushik
 
PDF
mlflow: Accelerating the End-to-End ML lifecycle
Databricks
 
PPTX
Generative AI Application Development using LangChain and LangFlow
Gene Leybzon
 
PDF
Elasticsearch
Hermeto Romano
 
PPTX
Onnx and onnx runtime
Vishwas N
 
PDF
Introduction to Spring Boot!
Jakub Kubrynski
 
PDF
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
luisw19
 
PDF
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
Animesh Singh
 
PDF
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Edureka!
 
PPTX
How ChatGPT and AI-assisted coding changes software engineering profoundly
Pekka Abrahamsson / Tampere University
 
PPTX
A Comprehensive Review of Large Language Models for.pptx
SaiPragnaKancheti
 
MLflow Model Serving
Databricks
 
Introducing MlFlow: An Open Source Platform for the Machine Learning Lifecycl...
DataWorks Summit
 
Spark SQL Tutorial | Spark SQL Using Scala | Apache Spark Tutorial For Beginn...
Simplilearn
 
Graphql
Niv Ben David
 
Apache Kafka Architecture & Fundamentals Explained
confluent
 
"Managing the Complete Machine Learning Lifecycle with MLflow"
Databricks
 
REST vs GraphQL
Squareboat
 
Kubeflow Pipelines (with Tekton)
Animesh Singh
 
Use MLflow to manage and deploy Machine Learning model on Spark
Herman Wu
 
MLOps with Kubeflow
Saurabh Kaushik
 
mlflow: Accelerating the End-to-End ML lifecycle
Databricks
 
Generative AI Application Development using LangChain and LangFlow
Gene Leybzon
 
Elasticsearch
Hermeto Romano
 
Onnx and onnx runtime
Vishwas N
 
Introduction to Spring Boot!
Jakub Kubrynski
 
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
luisw19
 
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
Animesh Singh
 
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Edureka!
 
How ChatGPT and AI-assisted coding changes software engineering profoundly
Pekka Abrahamsson / Tampere University
 
A Comprehensive Review of Large Language Models for.pptx
SaiPragnaKancheti
 

Viewers also liked (20)

PDF
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...
Edureka!
 
PPTX
Top 5 Deep Learning and AI Stories - October 6, 2017
NVIDIA
 
PDF
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...
Edureka!
 
PPTX
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
Carol Smith
 
PDF
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
Edureka!
 
PDF
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Edureka!
 
PDF
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...
Edureka!
 
PPTX
What to Upload to SlideShare
SlideShare
 
PDF
What Is DevOps? | Introduction To DevOps | DevOps Tools | DevOps Tutorial | D...
Edureka!
 
PPTX
Oficinas de Proyectos Eficientes con Microsoft EPM 2010 (en Microsoft Uruguay)
Walter Ariel Risi
 
PPTX
Web social
Gianina Villar Soto
 
PPTX
Presentación Juan David Echeverri EPM
CQC MCI
 
PPTX
Importancia de las tic en la educación 3
lucerito8
 
PPTX
negociaciones de Epm
estefaniayaquer
 
PDF
13 caso-epm
Andesco
 
PPT
Taller Administración del tiempo
Gustavo Villegas L.
 
PDF
IFS Energy & Utilities Solution Map
IFS
 
PDF
[Tek] 4차산업혁명위원회 사회제도혁신위원회에 제출한 규제합리화 방안
TEK & LAW, LLP
 
PDF
Data Infrastructure at LinkedIn
Amy W. Tang
 
PPTX
Data Infrastructure at LinkedIn
Amy W. Tang
 
What is Artificial Intelligence | Artificial Intelligence Tutorial For Beginn...
Edureka!
 
Top 5 Deep Learning and AI Stories - October 6, 2017
NVIDIA
 
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...
Edureka!
 
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
Carol Smith
 
ReactJS Tutorial For Beginners | ReactJS Redux Training For Beginners | React...
Edureka!
 
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Edureka!
 
Angular 4 Data Binding | Two Way Data Binding in Angular 4 | Angular 4 Tutori...
Edureka!
 
What to Upload to SlideShare
SlideShare
 
What Is DevOps? | Introduction To DevOps | DevOps Tools | DevOps Tutorial | D...
Edureka!
 
Oficinas de Proyectos Eficientes con Microsoft EPM 2010 (en Microsoft Uruguay)
Walter Ariel Risi
 
Presentación Juan David Echeverri EPM
CQC MCI
 
Importancia de las tic en la educación 3
lucerito8
 
negociaciones de Epm
estefaniayaquer
 
13 caso-epm
Andesco
 
Taller Administración del tiempo
Gustavo Villegas L.
 
IFS Energy & Utilities Solution Map
IFS
 
[Tek] 4차산업혁명위원회 사회제도혁신위원회에 제출한 규제합리화 방안
TEK & LAW, LLP
 
Data Infrastructure at LinkedIn
Amy W. Tang
 
Data Infrastructure at LinkedIn
Amy W. Tang
 
Ad

Similar to Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tutorial | Edureka (20)

PDF
TensorFlow Tutorial | Deep Learning Using TensorFlow | TensorFlow Tutorial Py...
Edureka!
 
PDF
Deep Learning Tutorial | Deep Learning Tutorial for Beginners | Neural Networ...
Edureka!
 
PDF
Theano vs TensorFlow | Edureka
Edureka!
 
PPTX
Internship project presentation_final_upload
Suraj Rathore
 
PDF
Introduction to Tensor Flow for Optical Character Recognition (OCR)
Vincenzo Santopietro
 
PDF
Feature Engineering in NLP.pdf
bilaje4244prolugcom
 
PDF
TensorFlow example for AI Ukraine2016
Andrii Babii
 
PDF
Introduction to TensorFlow
Ralph Vincent Regalado
 
PDF
Metrics 2.0 @ Monitorama PDX 2014
Dieter Plaetinck
 
PDF
Natural language processing open seminar For Tensorflow usage
hyunyoung Lee
 
DOCX
Computer project
Czarina Patalod
 
PPTX
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
Simplilearn
 
PDF
MySQL Optimizer: What’s New in 8.0
oysteing
 
PPTX
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Simplilearn
 
DOCX
Base sas interview questions
Sunil0108
 
PPTX
Certification Study Group -Professional ML Engineer Session 2 (GCP-TensorFlow...
gdgsurrey
 
PPTX
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
DOCX
Base sas interview questions
Dr P Deepak
 
PDF
Deep Learning Introduction - WeCloudData
WeCloudData
 
PDF
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
TensorFlow Tutorial | Deep Learning Using TensorFlow | TensorFlow Tutorial Py...
Edureka!
 
Deep Learning Tutorial | Deep Learning Tutorial for Beginners | Neural Networ...
Edureka!
 
Theano vs TensorFlow | Edureka
Edureka!
 
Internship project presentation_final_upload
Suraj Rathore
 
Introduction to Tensor Flow for Optical Character Recognition (OCR)
Vincenzo Santopietro
 
Feature Engineering in NLP.pdf
bilaje4244prolugcom
 
TensorFlow example for AI Ukraine2016
Andrii Babii
 
Introduction to TensorFlow
Ralph Vincent Regalado
 
Metrics 2.0 @ Monitorama PDX 2014
Dieter Plaetinck
 
Natural language processing open seminar For Tensorflow usage
hyunyoung Lee
 
Computer project
Czarina Patalod
 
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Be...
Simplilearn
 
MySQL Optimizer: What’s New in 8.0
oysteing
 
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Simplilearn
 
Base sas interview questions
Sunil0108
 
Certification Study Group -Professional ML Engineer Session 2 (GCP-TensorFlow...
gdgsurrey
 
Pythonlearn-02-Expressions123AdvanceLevel.pptx
AninditaSarkarNaha
 
Base sas interview questions
Dr P Deepak
 
Deep Learning Introduction - WeCloudData
WeCloudData
 
03-Variables, Expressions and Statements (1).pdf
MirHazarKhan1
 
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
PDF
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
PDF
Tableau Tutorial for Data Science | Edureka
Edureka!
 
PDF
Python Programming Tutorial | Edureka
Edureka!
 
PDF
Top 5 PMP Certifications | Edureka
Edureka!
 
PDF
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
PDF
Linux Mint Tutorial | Edureka
Edureka!
 
PDF
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
PDF
Importance of Digital Marketing | Edureka
Edureka!
 
PDF
RPA in 2020 | Edureka
Edureka!
 
PDF
Email Notifications in Jenkins | Edureka
Edureka!
 
PDF
EA Algorithm in Machine Learning | Edureka
Edureka!
 
PDF
Cognitive AI Tutorial | Edureka
Edureka!
 
PDF
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
PDF
Blue Prism Top Interview Questions | Edureka
Edureka!
 
PDF
Big Data on AWS Tutorial | Edureka
Edureka!
 
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
PDF
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
PDF
Introduction to DevOps | Edureka
Edureka!
 
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Edureka!
 

Recently uploaded (20)

PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Digital Circuits, important subject in CS
contactparinay1
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 

Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tutorial | Edureka

  • 1. Agenda ▪ Difference Between Machine Learning and Deep Learning ▪ What is Deep Learning? ▪ What is TensorFlow? ▪ TensorFlow Data Structures ▪ TensorFlow Use-Case
  • 2. Agenda ▪ Difference Between Machine Learning and Deep Learning ▪ What is Deep Learning? ▪ What is TensorFlow? ▪ TensorFlow Data Structures ▪ TensorFlow Use-Case
  • 3. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning vs Deep Learning Let’s see what are the differences between Machine Learning and Deep Learning
  • 4. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning vs Deep Learning Machine Learning Deep Learning High performance on less data Low performance on less data Deep Learning Performance Machine Learning Performance
  • 5. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning vs Deep Learning Machine Learning Deep Learning Can work on low end machines Requires high end machines
  • 6. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Machine Learning vs Deep Learning Machine Learning Deep Learning Features need to be hand-coded as per the domain and data type Tries to learn high-level features from data
  • 7. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What is Deep Learning? Now is the time to understand what exactly is Deep Learning?
  • 8. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What is Deep Learning? Input Layer Hidden Layer 1 Hidden Layer 2 Output Layer A collection of statistical machine learning techniques used to learn feature hierarchies often based on artificial neural networks
  • 9. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What are Tensors? Let’s see what are Tensors?
  • 10. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What Are Tensors?  Tensors are the standard way of representing data in TensorFlow (deep learning).  Tensors are multidimensional arrays, an extension of two-dimensional tables (matrices) to data with higher dimension. Tensor of dimension[1] Tensor of dimensions[2] Tensor of dimensions[3]
  • 11. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Tensors Rank Rank Math Entity Python Example 0 Scalar (magnitude only) s = 483 1 Vector (magnitude and direction) v = [1.1, 2.2, 3.3] 2 Matrix (table of numbers) m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 3 3-Tensor (cube of numbers) t = [[[2], [4], [6]], [[8], [10], [12]], [[14], [16], [18 ]]] n n-Tensor (you get the idea) ....
  • 12. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Tensor Data Types In addition to dimensionality Tensors have different data types as well, you can assign any one of these data types to a Tensor
  • 13. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What Is TensorFlow? Now, is the time explore TensorFlow.
  • 14. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What Is TensorFlow?  TensorFlow is a Python library used to implement deep networks.  In TensorFlow, computation is approached as a dataflow graph. 3.2 -1.4 5.1 … -1.0 -2 2.4 … … … … … … … … … Tensor Flow Matmul W X Add Relu B Computational Graph Functions Tensors
  • 15. Copyright © 2017, edureka and/or its affiliates. All rights reserved. TensorFlow Code-Basics Let’s understand the fundamentals of TensorFlow
  • 16. Copyright © 2017, edureka and/or its affiliates. All rights reserved. TensorFlow Code-Basics TensorFlow core programs consists of two discrete sections: Building a computational graph Running a computational graph A computational graph is a series of TensorFlow operations arranged into a graph of nodes
  • 17. Copyright © 2017, edureka and/or its affiliates. All rights reserved. TensorFlow Building And Running A Graph Building a computational graph Running a computational graph import tensorflow as tf node1 = tf.constant(3.0, tf.float32) node2 = tf.constant(4.0) print(node1, node2) Constant nodes sess = tf.Session() print(sess.run([node1, node2])) To actually evaluate the nodes, we must run the computational graph within a session. As the session encapsulates the control and state of the TensorFlow runtime.
  • 18. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Tensorflow Example a 5.0 Constimport tensorflow as tf # Build a graph a = tf.constant(5.0) b = tf.constant(6.0) c = a * b # Launch the graph in a session sess = tf.Session() # Evaluate the tensor 'C' print(sess.run(c)) Computational Graph
  • 19. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Tensorflow Example a b 5.0 6.0 Const Constimport tensorflow as tf # Build a graph a = tf.constant(5.0) b = tf.constant(6.0) c = a * b # Launch the graph in a session sess = tf.Session() # Evaluate the tensor 'C' print(sess.run(c)) Computational Graph
  • 20. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Tensorflow Example a b c 5.0 6.0 Const Mul Constimport tensorflow as tf # Build a graph a = tf.constant(5.0) b = tf.constant(6.0) c = a * b # Launch the graph in a session sess = tf.Session() # Evaluate the tensor 'C' print(sess.run(c)) Computational Graph
  • 21. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Tensorflow Example a b c 5.0 6.0 Const Mul 30.0 Constimport tensorflow as tf # Build a graph a = tf.constant(5.0) b = tf.constant(6.0) c = a * b # Launch the graph in a session sess = tf.Session() # Evaluate the tensor 'C' print(sess.run(c)) Running The Computational Graph
  • 22. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Graph Visualization
  • 23. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Graph Visualization  For visualizing TensorFlow graphs, we use TensorBoard.  The first argument when creating the FileWriter is an output directory name, which will be created if it doesn't exist. File_writer = tf.summary.FileWriter('log_simple_graph', sess.graph) TensorBoard runs as a local web app, on port 6006. (this is default port, “6006” is “ ” upside-down.)oo tensorboard --logdir = “path_to_the_graph” Execute this command in the cmd
  • 24. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Constants, Placeholders and Variables Let’s understand what are constants, placeholders and variables
  • 25. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Constant One type of a node is a constant. It takes no inputs, and it outputs a value it stores internally. import tensorflow as tf node1 = tf.constant(3.0, tf.float32) node2 = tf.constant(4.0) print(node1, node2) Constant nodes Constant Placeholder Variable
  • 26. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Constant One type of a node is a constant. It takes no inputs, and it outputs a value it stores internally. import tensorflow as tf node1 = tf.constant(3.0, tf.float32) node2 = tf.constant(4.0) print(node1, node2) Constant nodes Constant Placeholder Variable What if I want the graph to accept external inputs?
  • 27. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Placeholder Constant Placeholder Variable A graph can be parameterized to accept external inputs, known as placeholders. A placeholder is a promise to provide a value later.
  • 28. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Placeholder Constant Placeholder Variable A graph can be parameterized to accept external inputs, known as placeholders. A placeholder is a promise to provide a value later. How to modify the graph, if I want new output for the same input ?
  • 29. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Variable Constant Placeholder Variable To make the model trainable, we need to be able to modify the graph to get new outputs with the same input. Variables allow us to add trainable parameters to a graph
  • 30. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Let Us Now Create A Model
  • 31. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Simple Linear Model import tensorflow as tf W = tf.Variable([.3], tf.float32) b = tf.Variable([-.3], tf.float32) x = tf.placeholder(tf.float32) linear_model = W * x + b init = tf.global_variables_initializer() sess = tf.Session() sess.run(init) print(sess.run(linear_model, {x:[1,2,3,4]})) We've created a model, but we don't know how good it is yet
  • 32. Copyright © 2017, edureka and/or its affiliates. All rights reserved. How To Increase The Efficiency Of The Model? Calculate the loss Model Update the Variables Repeat the process until the loss becomes very small A loss function measures how far apart the current model is from the provided data.
  • 33. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Calculating The Loss In order to understand how good the Model is, we should know the loss/error. To evaluate the model on training data, we need a y i.e. a placeholder to provide the desired values, and we need to write a loss function. We'll use a standard loss model for linear regression. (linear_model – y ) creates a vector where each element is the corresponding example's error delta. tf.square is used to square that error. tf.reduce_sum is used to sum all the squared error. y = tf.placeholder(tf.float32) squared_deltas = tf.square(linear_model - y) loss = tf.reduce_sum(squared_deltas) print(sess.run(loss, {x:[1,2,3,4], y:[0,-1,-2,-3]}))
  • 34. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Reducing The Loss Optimizer modifies each variable according to the magnitude of the derivative of loss with respect to that variable. Here we will use Gradient Descent Optimizer How Gradient Descent Actually Works? Let’s understand this with an analogy
  • 35. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Reducing The Loss • Suppose you are at the top of a mountain, and you have to reach a lake which is at the lowest point of the mountain (a.k.a valley). • A twist is that you are blindfolded and you have zero visibility to see where you are headed. So, what approach will you take to reach the lake?
  • 36. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Reducing The Loss • The best way is to check the ground near you and observe where the land tends to descend. • This will give an idea in what direction you should take your first step. If you follow the descending path, it is very likely you would reach the lake. Consider the length of the step as learning rate Consider the position of the hiker as weight Consider the process of climbing down the mountain as cost function/loss function
  • 37. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Reducing The Loss Global Cost/Loss Minimum Jmin(w) J(w) Let us understand the math behind Gradient Descent
  • 38. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Batch Gradient Descent The weights are updated incrementally after each epoch. The cost function J(⋅), the sum of squared errors (SSE), can be written as:
  • 39. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Batch Gradient Descent The weights are updated incrementally after each epoch. The cost function J(⋅), the sum of squared errors (SSE), can be written as: The magnitude and direction of the weight update is computed by taking a step in the opposite direction of the cost gradient
  • 40. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Batch Gradient Descent The weights are updated incrementally after each epoch. The cost function J(⋅), the sum of squared errors (SSE), can be written as: The magnitude and direction of the weight update is computed by taking a step in the opposite direction of the cost gradient The weights are then updated after each epoch via the following update rule:
  • 41. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Batch Gradient Descent The weights are updated incrementally after each epoch. The cost function J(⋅), the sum of squared errors (SSE), can be written as: The magnitude and direction of the weight update is computed by taking a step in the opposite direction of the cost gradient The weights are then updated after each epoch via the following update rule: Here, Δw is a vector that contains the weight updates of each weight coefficient w, which are computed as follows:
  • 42. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Reducing The Loss Suppose, we want to find the best parameters (W) for our learning algorithm. We can apply the same analogy and find the best possible values for that parameter. Consider the example below: optimizer = tf.train.GradientDescentOptimizer(0.01) train = optimizer.minimize(loss) sess.run(init) for i in range(1000): sess.run(train, {x:[1,2,3,4], y:[0,-1,-2,-3]}) print(sess.run([W, b]))
  • 43. Copyright © 2017, edureka and/or its affiliates. All rights reserved. TensorFlow Use-Case
  • 44. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Long Short Term Memory Networks Use-Case We will feed a LSTM with correct sequences from the text of 3 symbols as inputs and 1 labeled symbol, eventually the neural network will learn to predict the next symbol correctly had a general LSTM cell Council Prediction label vs inputs LSTM cell with three inputs and 1 output.
  • 45. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Long Short Term Memory Networks Use-Case long ago , the mice had a general council to consider what measures they could take to outwit their common enemy , the cat . some said this , and some said that but at last a young mouse got up and said he had a proposal to make , which he thought would meet the case . you will all agree , said he , that our chief danger consists in the sly and treacherous manner in which the enemy approaches us . now , if we could receive some signal of her approach , we could easily escape from her . i venture , therefore , to propose that a small bell be procured , and attached by a ribbon round the neck of the cat . by this means we should always know when she was about , and could easily retire while she was in the neighborhood . this proposal met with general applause , until an old mouse got up and said that is all very well , but who is to bell the cat ? the mice looked at one another and nobody spoke . then the old mouse said it is easy to propose impossible remedies . How to train the network? A short story from Aesop’s Fables with 112 unique symbols
  • 46. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Long Short Term Memory Networks Use-Case A unique integer value is assigned to each symbol because LSTM inputs can only understand real numbers. 20 6 33 LSTM cell LSTM cell with three inputs and 1 output. had a general .01 .02 .6 .00 37 37 vs Council Council 112-element vector
  • 47. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Session In A Minute Machine Learning vs Deep Learning What is Deep Learning? What is TensorFlow? TensorFlow Code-Basics Simple Linear Model TensorFlow Use-Case
  • 48. Copyright © 2017, edureka and/or its affiliates. All rights reserved.