SlideShare a Scribd company logo
TensorFlow Tutorial
Detecting Diabetic Retinopathy
Diabetic Retinopathy is the fastest growing cause of blindness in the world. Deep Learning algorithms using TensorFlow are
capable of interpreting signs of Diabetic Retinopathy in retinal photographs.
128,000 images of eye retina’s
Fed to a Neural Network
for training
New image of eye retina Identifies Healthy and
Diseased eye
What’s in it for you?
What is Deep Learning?
What is TensorFlow?
Top Deep Learning Libraries
Why use TensorFlow?
Building a Computational Graph
Programming Elements in TensorFlow
Introducing Recurrent Neural Networks
Use case implementation of RNN using TensorFlow
What is Deep learning?
Subset of Machine Learning and works
on the structure and functions of a
human brain
Learns from unstructured data and
performs complex computations
Uses a Neural Net with multiple layers to
train an algorithm
Deep Learning Input Layer Hidden
Layers
Output
Layer
Popular libraries for Deep Learning
TensorFlow
Deep Learning 4
Java
TheanoTorch
Keras
Deep Learning Libraries
Why use TensorFlow?
Provides both C++ and Python
API’s that makes it easier to
work on
TensorFlow reduces the
chances of errors by 55% to
85%
Teams can run TensorFlow on
large scale server farms
embedded on devices, CPUs,
GPUs, TPUs, etc
TensorFlow allows you to train
models faster as it has faster
compilation time
What is TensorFlow?
TensorFlow
Open source library
developed by Google brain
team in 2012
Developed initially to run large
sets of numerical
computations
Uses Data Flow graphs to
process data and perform
computations
Takes data in the form of
arrays of potentially higher
dimensions and ranks
What is a Tensor?
Tensor is a mathematical object represented as arrays of higher dimensions. These arrays of data with different
dimensions and ranks that are fed as input to the neural network are called Tensors.
Arrays of data with
different dimensions is
fed as input to the
network
Input Layer Hidden Layers Output Layer
a
m
k
q
d
Tensor of Dimensions[5]
What is a Tensor?
Tensor is a mathematical object represented as arrays of higher dimensions. These arrays of data with different
dimensions and ranks that are fed as input to the neural network are called Tensors.
Input Layer Hidden Layers Output Layer
1
6
8
3
9
3
3
4
1
7
4
9
1
5
3
7
1
6
9
2
Tensor of Dimensions[5,4]
What is a Tensor?
Tensor is a mathematical object represented as arrays of higher dimensions. These arrays of data with different
dimensions and ranks that are fed as input to the neural network are called Tensors.
Input Layer Hidden Layers Output Layer
Tensor of Dimensions[3,3,3]
Tensor Rank
The number of dimensions used to represent the data is known as its Rank.
S = 10 Tensor of Rank 0 or a Scalar.
Tensor of Rank 1 or a Vector.V = [10., 11., 12.]
M = [[1, 2, 3],[4, 5, 6]] Tensor of Rank 2 or a Matrix.
T = [[[1],[2],[3]],[[4],[5],[6]],[[7],[8],[9]]] Tensor of Rank 3 or a Tensor
Tensor Data type
Data Type Python Type Description
DF_FLOAT tf.float32 32 bits floating point
DF_DOUBLE tf.float64 64 bits floating point
DT_INT8 tf.int8 8 bits signed integer
DT_INT16 tf.int16 16 bits signed integer
DT_INT32 tf.int32 32 bits signed integer
DT_INT64 tf.int64 64 bits signed integer
DT_UINT8 tf.unit8 8 bits unsigned integer
DT_STRING tf.string Variable length byte arrays
DT_BOOL tf.bool Boolean
In addition to rank and shape, Tensors have a data type. Following is the list of the data type:
Building a Computation Graph
Everything in TensorFlow is based on creating a computational graph. It has a network of nodes, with each
node performing an operation like addition, multiplication or evaluating some multivariate equation.
input
input
add
mul
mul
a
b
c
d
e
5
3
4
2
7
1
2
84
In TensorFlow, a computation is described
using a Data Flow graph
Nodes represent mathematical operation and
edge represents tensors
Building a Computation Graph
Lets compute a function F of 3 variables a, b, c : F(a,b,c) = 5(a+bc)
p = bc
q = a + p
F = 5*q
a=4
b=3
c=5
p = bc
q = a + p F = 5*q
15
19 95
Programming elements in TensorFlow
Constants
Constants are parameters whose value does not
change. 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)
Programming elements in TensorFlow
Variables
Variables allow us to add new trainable parameters to
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
Programming elements in TensorFlow
Placeholder
Placeholders allow us to feed data to a tensorflow model
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:
result = sess.run(b,feed_dict={a:3.0})
print result
feed_dict specifies tensors
that provide concrete values to
the placeholders
Programming elements in TensorFlow
Session
A session is run to evaluate the nodes. This is called as
the TensorFlow runtime.
Example:
a = tf.constant(2.0)
b = tf.constant(4.0)
c = a+b
# Launch Session
sess = tf.Session()
# Evaluate the tensor c
print(sess.run(c))
Running a Computation
Graph
a
b
c
4.0
2.0
Addition
6.0
Linear Regression using TensorFlow
Let’s work on a regression example to solve a simple equation [y=m*x+b]. We will calculate the slope and the intercept of the
line that best fits our data.
1. Setting up some artificial data for regression
Linear Regression using TensorFlow
2. Plot the Data
Linear Regression using TensorFlow
3. Assign the variables
4. Apply the Cost Function
Linear Regression using TensorFlow
5. Apply the Optimization function
6. Initialize the variables
7. Create the session and run the computation
Linear Regression using TensorFlow
8. Print the slope and intercept
Linear Regression using TensorFlow
9. Evaluate the results
Introducing Recurrent Neural Networks
In a Feed-Forward Network like CNN/ANN, information flows only in forward direction, from the input nodes, through the
hidden layers (if any) and to the output nodes. There are no cycles or loops in the network.
Input Layer Hidden Layers Output Layer
Feed-Forward Network
Yellow
Patch
Petals length
and width
Sepals length
and width
Output
Iris
Not Iris
Introducing Recurrent Neural Networks
Recurrent Neural Networks are used to handle sequential time series data because it is able to memorize the inputs. At a
particular time step, RNN accepts previous output result along with the current input to generate the output at that time step.
Recurrent Neural Network
h
x
y
w
Rotate the neural network
vertically and compress the
layers
How does a Recurrent Neural Network look like?
h
x
y
w Unfold ht-1
xt-1
yt-1
ht
xt
yt
ht+1
xt+1
yt+1
w ww w
Input at time t
Output at time t
Hidden state at
time t
ht = f (ht-1 ,xtw )
ht = new state
fw = function with parameter w
ht-1
= old state
xt = input vector at time step t
Types of RNN
While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one
and many to many.
One to One One to Many Many to One Many to Many
Types of RNN
While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one
and many to many.
One to One One to Many Many to One Many to Many
• Known as the Vanilla Neural Network. Used for
regular machine learning problems
1 output
1 input
Types of RNN
While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one
and many to many.
One to One One to Many Many to One Many to Many
• Used for image captioning. Given an image, it
generate a sequence of words, captioning the
image
multiple
outputs
1 input
Types of RNN
While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one
and many to many.
One to One One to Many Many to One Many to Many
• Used to carry out Sentiment Analysis. Given a
set of words, it tells you the sentiment present
1 output
multiple
inputs
Types of RNN
While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one
and many to many.
One to One One to Many Many to One Many to Many
• Used in Machine Translation. Given a sets of
words in one language, it translates it to
another
multiple
inputs
multiple
outputs
Use case implementation of RNN
Lets look at a use case of predicting the monthly milk production
per cow in pounds using a time series data
Based on
Data between Jan 1962 to
Dec 1975
How much milk
production can we
expect in a
month?
Use case implementation of RNN
1. Import the necessary libraries
2. Read the dataset and print the head of it
Use case implementation of RNN
3. Convert the index to time series
4. Plot the time series data
Use case implementation of RNN
5. Perform the train test split on the data
Use case implementation of RNN
6. Scale the data using standard Machine Learning process
7. Applying the batch function
Use case implementation of RNN
8. Setting up the RNN model
Use case implementation of RNN
9. Create Placeholders for X and y
10. Applying the loss function and optimizer
11. Initialize the Global variables
12. Create an instance of tf.train.Saver()
Use case implementation of RNN
13. Create the session and run it
Use case implementation of RNN
14. Display the Test Data
Use case implementation of RNN
15. Create a seed training_instance to predict the last 12 months milk production from the training data
Use case implementation of RNN
16. Displaying the results of the prediction
Use case implementation of RNN
17. Reshape the results
18. Create a new column on the test data called Generated
Use case implementation of RNN
19. View the test_set dataframe
Use case implementation of RNN
20. Plot the predicted result and the actual result
Key Takeaways
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For Beginners |Simplilearn

More Related Content

What's hot (20)

PDF
Recurrent neural networks rnn
Kuppusamy P
 
PDF
Introduction to TensorFlow 2.0
Databricks
 
PDF
Deep Learning - Convolutional Neural Networks
Christian Perone
 
PPTX
Deep Learning With Python | Deep Learning And Neural Networks | Deep Learning...
Simplilearn
 
PDF
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
PDF
Keras Tutorial For Beginners | Creating Deep Learning Models Using Keras In P...
Edureka!
 
PDF
Attention is All You Need (Transformer)
Jeong-Gwan Lee
 
PPTX
Introduction to Deep learning
leopauly
 
PDF
Deep learning for NLP and Transformer
Arvind Devaraj
 
PDF
Introduction to Deep Learning, Keras, and TensorFlow
Sri Ambati
 
PPTX
Attention Is All You Need
Illia Polosukhin
 
PPTX
Introduction to Transformer Model
Nuwan Sriyantha Bandara
 
PPTX
Tensorflow - Intro (2017)
Alessio Tonioni
 
PDF
Deep Learning: Recurrent Neural Network (Chapter 10)
Larry Guo
 
PDF
Python NumPy Tutorial | NumPy Array | Edureka
Edureka!
 
PPTX
Introduction For seq2seq(sequence to sequence) and RNN
Hye-min Ahn
 
PDF
Deep Learning for Computer Vision: Data Augmentation (UPC 2016)
Universitat Politècnica de Catalunya
 
PPTX
Text similarity measures
ankit_ppt
 
PPTX
Deep Neural Networks (DNN)
Sir Syed University of Engineering & Technology
 
PDF
Machine Learning with TensorFlow 2
Sarah Stemmler
 
Recurrent neural networks rnn
Kuppusamy P
 
Introduction to TensorFlow 2.0
Databricks
 
Deep Learning - Convolutional Neural Networks
Christian Perone
 
Deep Learning With Python | Deep Learning And Neural Networks | Deep Learning...
Simplilearn
 
Convolutional Neural Network Models - Deep Learning
Mohamed Loey
 
Keras Tutorial For Beginners | Creating Deep Learning Models Using Keras In P...
Edureka!
 
Attention is All You Need (Transformer)
Jeong-Gwan Lee
 
Introduction to Deep learning
leopauly
 
Deep learning for NLP and Transformer
Arvind Devaraj
 
Introduction to Deep Learning, Keras, and TensorFlow
Sri Ambati
 
Attention Is All You Need
Illia Polosukhin
 
Introduction to Transformer Model
Nuwan Sriyantha Bandara
 
Tensorflow - Intro (2017)
Alessio Tonioni
 
Deep Learning: Recurrent Neural Network (Chapter 10)
Larry Guo
 
Python NumPy Tutorial | NumPy Array | Edureka
Edureka!
 
Introduction For seq2seq(sequence to sequence) and RNN
Hye-min Ahn
 
Deep Learning for Computer Vision: Data Augmentation (UPC 2016)
Universitat Politècnica de Catalunya
 
Text similarity measures
ankit_ppt
 
Machine Learning with TensorFlow 2
Sarah Stemmler
 

Similar to TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For Beginners |Simplilearn (20)

PDF
Language translation with Deep Learning (RNN) with TensorFlow
S N
 
PDF
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Edureka!
 
PPTX
TensorFlow.pptx
Jayesh Patil
 
PDF
Introduction to Neural Networks in Tensorflow
Nicholas McClure
 
PPTX
Neural networks and deep learning
RADO7900
 
PDF
Deep Learning Tutorial | Deep Learning Tutorial for Beginners | Neural Networ...
Edureka!
 
PPTX
Introduction to Deep Learning and TensorFlow
Oswald Campesato
 
PPTX
H2 o berkeleydltf
Oswald Campesato
 
PDF
TensorFlow example for AI Ukraine2016
Andrii Babii
 
PDF
DyCode Engineering - Machine Learning with TensorFlow
Alwin Arrasyid
 
PPTX
Introduction to Deep Learning, Keras, and Tensorflow
Oswald Campesato
 
PDF
TensorFlow Tutorial.pdf
Antonio Espinosa
 
PPTX
Deep Learning in Your Browser
Oswald Campesato
 
PPTX
TensorFlow in Your Browser
Oswald Campesato
 
PPTX
Deep Learning in your Browser: powered by WebGL
Oswald Campesato
 
PPTX
Intro to Deep Learning, TensorFlow, and tensorflow.js
Oswald Campesato
 
PPTX
C++ and Deep Learning
Oswald Campesato
 
PPTX
Lecture Note DL&NN Tensorflow.pptx
BhaviniBhatt7
 
PDF
Getting Started with Keras and TensorFlow - StampedeCon AI Summit 2017
StampedeCon
 
Language translation with Deep Learning (RNN) with TensorFlow
S N
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | TensorFlow Tuto...
Edureka!
 
TensorFlow.pptx
Jayesh Patil
 
Introduction to Neural Networks in Tensorflow
Nicholas McClure
 
Neural networks and deep learning
RADO7900
 
Deep Learning Tutorial | Deep Learning Tutorial for Beginners | Neural Networ...
Edureka!
 
Introduction to Deep Learning and TensorFlow
Oswald Campesato
 
H2 o berkeleydltf
Oswald Campesato
 
TensorFlow example for AI Ukraine2016
Andrii Babii
 
DyCode Engineering - Machine Learning with TensorFlow
Alwin Arrasyid
 
Introduction to Deep Learning, Keras, and Tensorflow
Oswald Campesato
 
TensorFlow Tutorial.pdf
Antonio Espinosa
 
Deep Learning in Your Browser
Oswald Campesato
 
TensorFlow in Your Browser
Oswald Campesato
 
Deep Learning in your Browser: powered by WebGL
Oswald Campesato
 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Oswald Campesato
 
C++ and Deep Learning
Oswald Campesato
 
Lecture Note DL&NN Tensorflow.pptx
BhaviniBhatt7
 
Getting Started with Keras and TensorFlow - StampedeCon AI Summit 2017
StampedeCon
 
Ad

More from Simplilearn (20)

PPTX
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
PPTX
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
PPTX
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
PPTX
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
PPTX
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
PPTX
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
PPTX
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
PPTX
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
PPTX
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
PPTX
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
PPTX
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
PPTX
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
PPTX
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
PPTX
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
PPTX
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
PPTX
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Ad

Recently uploaded (20)

PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Difference between write and update in odoo 18
Celine George
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 

TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For Beginners |Simplilearn

  • 2. Detecting Diabetic Retinopathy Diabetic Retinopathy is the fastest growing cause of blindness in the world. Deep Learning algorithms using TensorFlow are capable of interpreting signs of Diabetic Retinopathy in retinal photographs. 128,000 images of eye retina’s Fed to a Neural Network for training New image of eye retina Identifies Healthy and Diseased eye
  • 3. What’s in it for you? What is Deep Learning? What is TensorFlow? Top Deep Learning Libraries Why use TensorFlow? Building a Computational Graph Programming Elements in TensorFlow Introducing Recurrent Neural Networks Use case implementation of RNN using TensorFlow
  • 4. What is Deep learning? Subset of Machine Learning and works on the structure and functions of a human brain Learns from unstructured data and performs complex computations Uses a Neural Net with multiple layers to train an algorithm Deep Learning Input Layer Hidden Layers Output Layer
  • 5. Popular libraries for Deep Learning TensorFlow Deep Learning 4 Java TheanoTorch Keras Deep Learning Libraries
  • 6. Why use TensorFlow? Provides both C++ and Python API’s that makes it easier to work on TensorFlow reduces the chances of errors by 55% to 85% Teams can run TensorFlow on large scale server farms embedded on devices, CPUs, GPUs, TPUs, etc TensorFlow allows you to train models faster as it has faster compilation time
  • 7. What is TensorFlow? TensorFlow Open source library developed by Google brain team in 2012 Developed initially to run large sets of numerical computations Uses Data Flow graphs to process data and perform computations Takes data in the form of arrays of potentially higher dimensions and ranks
  • 8. What is a Tensor? Tensor is a mathematical object represented as arrays of higher dimensions. These arrays of data with different dimensions and ranks that are fed as input to the neural network are called Tensors. Arrays of data with different dimensions is fed as input to the network Input Layer Hidden Layers Output Layer a m k q d Tensor of Dimensions[5]
  • 9. What is a Tensor? Tensor is a mathematical object represented as arrays of higher dimensions. These arrays of data with different dimensions and ranks that are fed as input to the neural network are called Tensors. Input Layer Hidden Layers Output Layer 1 6 8 3 9 3 3 4 1 7 4 9 1 5 3 7 1 6 9 2 Tensor of Dimensions[5,4]
  • 10. What is a Tensor? Tensor is a mathematical object represented as arrays of higher dimensions. These arrays of data with different dimensions and ranks that are fed as input to the neural network are called Tensors. Input Layer Hidden Layers Output Layer Tensor of Dimensions[3,3,3]
  • 11. Tensor Rank The number of dimensions used to represent the data is known as its Rank. S = 10 Tensor of Rank 0 or a Scalar. Tensor of Rank 1 or a Vector.V = [10., 11., 12.] M = [[1, 2, 3],[4, 5, 6]] Tensor of Rank 2 or a Matrix. T = [[[1],[2],[3]],[[4],[5],[6]],[[7],[8],[9]]] Tensor of Rank 3 or a Tensor
  • 12. Tensor Data type Data Type Python Type Description DF_FLOAT tf.float32 32 bits floating point DF_DOUBLE tf.float64 64 bits floating point DT_INT8 tf.int8 8 bits signed integer DT_INT16 tf.int16 16 bits signed integer DT_INT32 tf.int32 32 bits signed integer DT_INT64 tf.int64 64 bits signed integer DT_UINT8 tf.unit8 8 bits unsigned integer DT_STRING tf.string Variable length byte arrays DT_BOOL tf.bool Boolean In addition to rank and shape, Tensors have a data type. Following is the list of the data type:
  • 13. Building a Computation Graph Everything in TensorFlow is based on creating a computational graph. It has a network of nodes, with each node performing an operation like addition, multiplication or evaluating some multivariate equation. input input add mul mul a b c d e 5 3 4 2 7 1 2 84 In TensorFlow, a computation is described using a Data Flow graph Nodes represent mathematical operation and edge represents tensors
  • 14. Building a Computation Graph Lets compute a function F of 3 variables a, b, c : F(a,b,c) = 5(a+bc) p = bc q = a + p F = 5*q a=4 b=3 c=5 p = bc q = a + p F = 5*q 15 19 95
  • 15. Programming elements in TensorFlow Constants Constants are parameters whose value does not change. 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)
  • 16. Programming elements in TensorFlow Variables Variables allow us to add new trainable parameters to 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
  • 17. Programming elements in TensorFlow Placeholder Placeholders allow us to feed data to a tensorflow model 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: result = sess.run(b,feed_dict={a:3.0}) print result feed_dict specifies tensors that provide concrete values to the placeholders
  • 18. Programming elements in TensorFlow Session A session is run to evaluate the nodes. This is called as the TensorFlow runtime. Example: a = tf.constant(2.0) b = tf.constant(4.0) c = a+b # Launch Session sess = tf.Session() # Evaluate the tensor c print(sess.run(c)) Running a Computation Graph a b c 4.0 2.0 Addition 6.0
  • 19. Linear Regression using TensorFlow Let’s work on a regression example to solve a simple equation [y=m*x+b]. We will calculate the slope and the intercept of the line that best fits our data. 1. Setting up some artificial data for regression
  • 20. Linear Regression using TensorFlow 2. Plot the Data
  • 21. Linear Regression using TensorFlow 3. Assign the variables 4. Apply the Cost Function
  • 22. Linear Regression using TensorFlow 5. Apply the Optimization function 6. Initialize the variables 7. Create the session and run the computation
  • 23. Linear Regression using TensorFlow 8. Print the slope and intercept
  • 24. Linear Regression using TensorFlow 9. Evaluate the results
  • 25. Introducing Recurrent Neural Networks In a Feed-Forward Network like CNN/ANN, information flows only in forward direction, from the input nodes, through the hidden layers (if any) and to the output nodes. There are no cycles or loops in the network. Input Layer Hidden Layers Output Layer Feed-Forward Network Yellow Patch Petals length and width Sepals length and width Output Iris Not Iris
  • 26. Introducing Recurrent Neural Networks Recurrent Neural Networks are used to handle sequential time series data because it is able to memorize the inputs. At a particular time step, RNN accepts previous output result along with the current input to generate the output at that time step. Recurrent Neural Network h x y w Rotate the neural network vertically and compress the layers
  • 27. How does a Recurrent Neural Network look like? h x y w Unfold ht-1 xt-1 yt-1 ht xt yt ht+1 xt+1 yt+1 w ww w Input at time t Output at time t Hidden state at time t ht = f (ht-1 ,xtw ) ht = new state fw = function with parameter w ht-1 = old state xt = input vector at time step t
  • 28. Types of RNN While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one and many to many. One to One One to Many Many to One Many to Many
  • 29. Types of RNN While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one and many to many. One to One One to Many Many to One Many to Many • Known as the Vanilla Neural Network. Used for regular machine learning problems 1 output 1 input
  • 30. Types of RNN While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one and many to many. One to One One to Many Many to One Many to Many • Used for image captioning. Given an image, it generate a sequence of words, captioning the image multiple outputs 1 input
  • 31. Types of RNN While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one and many to many. One to One One to Many Many to One Many to Many • Used to carry out Sentiment Analysis. Given a set of words, it tells you the sentiment present 1 output multiple inputs
  • 32. Types of RNN While Feed-Forward Networks map one input to one output, Recurrent Neural Networks can map one to many, many to one and many to many. One to One One to Many Many to One Many to Many • Used in Machine Translation. Given a sets of words in one language, it translates it to another multiple inputs multiple outputs
  • 33. Use case implementation of RNN Lets look at a use case of predicting the monthly milk production per cow in pounds using a time series data Based on Data between Jan 1962 to Dec 1975 How much milk production can we expect in a month?
  • 34. Use case implementation of RNN 1. Import the necessary libraries 2. Read the dataset and print the head of it
  • 35. Use case implementation of RNN 3. Convert the index to time series 4. Plot the time series data
  • 36. Use case implementation of RNN 5. Perform the train test split on the data
  • 37. Use case implementation of RNN 6. Scale the data using standard Machine Learning process 7. Applying the batch function
  • 38. Use case implementation of RNN 8. Setting up the RNN model
  • 39. Use case implementation of RNN 9. Create Placeholders for X and y 10. Applying the loss function and optimizer 11. Initialize the Global variables 12. Create an instance of tf.train.Saver()
  • 40. Use case implementation of RNN 13. Create the session and run it
  • 41. Use case implementation of RNN 14. Display the Test Data
  • 42. Use case implementation of RNN 15. Create a seed training_instance to predict the last 12 months milk production from the training data
  • 43. Use case implementation of RNN 16. Displaying the results of the prediction
  • 44. Use case implementation of RNN 17. Reshape the results 18. Create a new column on the test data called Generated
  • 45. Use case implementation of RNN 19. View the test_set dataframe
  • 46. Use case implementation of RNN 20. Plot the predicted result and the actual result

Editor's Notes