SlideShare a Scribd company logo
What is TensorFlow?
Agenda
What are Tensors?
What is Deep Learning?
What is TensorFlow?
Top Deep Learning Libraries
What is a Data Flow Graph?
Why TensorFlow?
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.
Input Layer Hidden Layers Output Layer
Accepts large volumes of data as
input to build the network
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
Processes the data by performing
complex operations and carries out
feature extraction
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
Generate the predicted
output by applying suitable
activation functions
Top Deep Learning Libraries
1 2 3 4 5
• Developed by Francois Chollet
• Open source library written in Python
• Developed by University of Montreal
• Written in Python
• Developed by Google Brain Team
• Written in C++, Python and CUDA
• Created by Ronan Collobert, Koray
kavukcuoglu, Clement Farabet
• Written in Python
• Developed by Skymind engineering
team and DeepLearning4J
community
• Written in C++ and Java
Why TensorFlow?
Provides both C++
and Python API’s
that makes it easier
to work on
Why TensorFlow?
Provides both C++
and Python API’s
that makes it easier
to work on
Has a faster
compilation time than
other Deep Learning
libraries like Keras and
Torch
Why TensorFlow?
Provides both C++
and Python API’s
that makes it easier
to work on
Has a faster
compilation time than
other Deep Learning
libraries like Keras and
Torch
TensorFlow supports
both CPU’s and
GPU’s computing
devices
What is TensorFlow?
Works on the basis of Data Flow graphs that have nodes and edges
Open source library developed by Google
Developed originally to run large numerical computations
Accepts data in the form of multidimensional arrays of higher dimensions called Tensors
2
8
1
7
5
Nodes
Edges
What is TensorFlow?
Works on the basis of Data Flow graphs that have nodes and edges
Open source library developed by Google
Developed originally to run large numerical computations
Accepts data in the form of multidimensional arrays of higher dimensions called Tensors
2
8
1
7
5
Nodes
Edges
What is TensorFlow?
Works on the basis of Data Flow graphs that have nodes and edges
Open source library developed by Google
Developed originally to run large numerical computations
Accepts data in the form of multidimensional arrays of higher dimensions called Tensors
2
8
1
7
5
Nodes
Edges
What is TensorFlow?
Works on the basis of Data Flow graphs that have nodes and edges
Open source library developed by Google
Developed originally to run large numerical computations
Accepts data in the form of multidimensional arrays of higher dimensions called Tensors
2
8
1
7
5
Nodes
Edges
What are 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.
Tensors
3
2
8
1
2
5
5
1
4
6
4
9
3
2
7
Data in the form of
arrays is fed as input to
the network
Input Layer Hidden Layers Output Layer
What are Tensors?
Tensors
a
m
k
q
d
Tensor of Dimensions[5]Different Dimensions
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.
What are Tensors?
Tensors
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]Different Dimensions
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.
What are Tensors?
Tensors
Different Dimensions Tensor of Dimensions[3,3,3]
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.
Tensor Ranks
m=V=[1,2,3],[4,5,6]
v=[10,11,12]
t=[[[1],[2],[3]],[[4],[5],[6]],[[7],[8],[9]]]
s= [200]
Tensor of Rank 0 Tensor of Rank 1
Tensor of Rank 2Tensor of Rank 3
What is a Data Flow graph?
Source: TensorFlow website
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
Program Elements in TensorFlow
TensorFlow
programs work
on two basic
concept
Building a
computational
graph
Executing a
computational
graph
Step 2
Step 1
Program 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)
Program 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
Program Elements in TensorFlow
Variable
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
Program Elements in TensorFlow
Session
A session is run to evaluate the nodes. This is called as the
TensorFlow runtime.
Example:
a = tf.constant(5.0)
b = tf.constant(3.0)
c = a*b
# Launch Session
sess = tf.Session()
# Evaluate the tensor c
print(sess.run(c))
5.0
3.0
15.0
Multiplication
Running a Computation
Graph
TensorFlow program basics
HelloWorld using TensorFlow
TensorFlow program basics
Variables in TensorFlow
TensorFlow program basics
Placeholders in TensorFlow
TensorFlow program basics
Performing Computations using TensorFlow
TensorFlow program basics
Matrix Multiplication using 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
race
relationship
occupation
gender
workclass
education
education_num hours_per_week
capital_loss
capital_gain
income_bracket
native_country
Predict Income
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
Key Takeaways
What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Beginners | Simplilearn

More Related Content

PDF
Tensorflow presentation
PDF
Introduction to TensorFlow 2.0
PDF
Introduction to TensorFlow
PDF
TensorFlow and Keras: An Overview
PDF
Introduction To TensorFlow
PPTX
IoT - IT 423 ppt
PPTX
Iot ppt
PPTX
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Tensorflow presentation
Introduction to TensorFlow 2.0
Introduction to TensorFlow
TensorFlow and Keras: An Overview
Introduction To TensorFlow
IoT - IT 423 ppt
Iot ppt
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...

What's hot (20)

PDF
TensorFlow
PPTX
Introduction to Keras
PDF
Neural networks and deep learning
PPTX
Python Scipy Numpy
PPTX
Deep learning
PDF
Hyperparameter Optimization for Machine Learning
PPTX
Getting started with TensorFlow
PPTX
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
PPTX
Neural Networks with Google TensorFlow
PPTX
Deep Learning Tutorial | Deep Learning TensorFlow | Deep Learning With Neural...
PPTX
Introduction to CNN
PPTX
1.Introduction to deep learning
PPTX
Introduction to Named Entity Recognition
PDF
Introduction to Deep Learning, Keras, and TensorFlow
PDF
PyTorch Python Tutorial | Deep Learning Using PyTorch | Image Classifier Usin...
PPTX
Introduction to Deep Learning
PPTX
Regularization in deep learning
PPTX
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
PPTX
[AIoTLab]attention mechanism.pptx
PPTX
Tensorflow
TensorFlow
Introduction to Keras
Neural networks and deep learning
Python Scipy Numpy
Deep learning
Hyperparameter Optimization for Machine Learning
Getting started with TensorFlow
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Neural Networks with Google TensorFlow
Deep Learning Tutorial | Deep Learning TensorFlow | Deep Learning With Neural...
Introduction to CNN
1.Introduction to deep learning
Introduction to Named Entity Recognition
Introduction to Deep Learning, Keras, and TensorFlow
PyTorch Python Tutorial | Deep Learning Using PyTorch | Image Classifier Usin...
Introduction to Deep Learning
Regularization in deep learning
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
[AIoTLab]attention mechanism.pptx
Tensorflow
Ad

Similar to What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Beginners | Simplilearn (20)

PPTX
TensorFlow.pptx
PPTX
Lecture Note DL&NN Tensorflow.pptx
PDF
Advanced Spark and TensorFlow Meetup May 26, 2016
PPTX
Meetup tensorframes
PPTX
Introduction to Tensor Flow-v1.pptx
PPTX
TensorFlow Technology
PPTX
A TensorFlow ppt for the gdsc event used in my college.
PDF
"TensorFlow Basics: A GDSC VITB Studty jams"
PDF
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
PDF
Introduction To Using TensorFlow & Deep Learning
PDF
Lecture 4: Deep Learning Frameworks
PDF
Natural language processing open seminar For Tensorflow usage
PDF
TensorFlow example for AI Ukraine2016
PPTX
TENSORFLOW liberayin python language.pptx
PPTX
Tensorflow Ecosystem
PPTX
Hadoop training in mumbai
PDF
Tensorflow - Overview, Features And Advantages.pdf
PDF
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
PPTX
Introduction to tensorflow
PDF
dl-unit-3 materialdl-unit-3 material.pdf
TensorFlow.pptx
Lecture Note DL&NN Tensorflow.pptx
Advanced Spark and TensorFlow Meetup May 26, 2016
Meetup tensorframes
Introduction to Tensor Flow-v1.pptx
TensorFlow Technology
A TensorFlow ppt for the gdsc event used in my college.
"TensorFlow Basics: A GDSC VITB Studty jams"
Hands-on Learning with KubeFlow + Keras/TensorFlow 2.0 + TF Extended (TFX) + ...
Introduction To Using TensorFlow & Deep Learning
Lecture 4: Deep Learning Frameworks
Natural language processing open seminar For Tensorflow usage
TensorFlow example for AI Ukraine2016
TENSORFLOW liberayin python language.pptx
Tensorflow Ecosystem
Hadoop training in mumbai
Tensorflow - Overview, Features And Advantages.pdf
TENSORFLOW: ARCHITECTURE AND USE CASE - NASA SPACE APPS CHALLENGE by Gema Par...
Introduction to tensorflow
dl-unit-3 materialdl-unit-3 material.pdf
Ad

More from Simplilearn (20)

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

Recently uploaded (20)

PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Institutional Correction lecture only . . .
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Cell Structure & Organelles in detailed.
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
Pharma ospi slides which help in ospi learning
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
Basic Mud Logging Guide for educational purpose
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Types and Its function , kingdom of life
PPH.pptx obstetrics and gynecology in nursing
TR - Agricultural Crops Production NC III.pdf
Institutional Correction lecture only . . .
VCE English Exam - Section C Student Revision Booklet
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Cell Structure & Organelles in detailed.
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Supply Chain Operations Speaking Notes -ICLT Program

What is TensorFlow? | Introduction to TensorFlow | TensorFlow Tutorial For Beginners | Simplilearn

  • 2. Agenda What are Tensors? What is Deep Learning? What is TensorFlow? Top Deep Learning Libraries What is a Data Flow Graph? Why TensorFlow? Program Elements in TensorFlow Use case implementation using TensorFlow
  • 3. 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
  • 4. 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 Accepts large volumes of data as input to build the network
  • 5. 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 Processes the data by performing complex operations and carries out feature extraction
  • 6. 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 Generate the predicted output by applying suitable activation functions
  • 7. Top Deep Learning Libraries 1 2 3 4 5 • Developed by Francois Chollet • Open source library written in Python • Developed by University of Montreal • Written in Python • Developed by Google Brain Team • Written in C++, Python and CUDA • Created by Ronan Collobert, Koray kavukcuoglu, Clement Farabet • Written in Python • Developed by Skymind engineering team and DeepLearning4J community • Written in C++ and Java
  • 8. Why TensorFlow? Provides both C++ and Python API’s that makes it easier to work on
  • 9. Why TensorFlow? Provides both C++ and Python API’s that makes it easier to work on Has a faster compilation time than other Deep Learning libraries like Keras and Torch
  • 10. Why TensorFlow? Provides both C++ and Python API’s that makes it easier to work on Has a faster compilation time than other Deep Learning libraries like Keras and Torch TensorFlow supports both CPU’s and GPU’s computing devices
  • 11. What is TensorFlow? Works on the basis of Data Flow graphs that have nodes and edges Open source library developed by Google Developed originally to run large numerical computations Accepts data in the form of multidimensional arrays of higher dimensions called Tensors 2 8 1 7 5 Nodes Edges
  • 12. What is TensorFlow? Works on the basis of Data Flow graphs that have nodes and edges Open source library developed by Google Developed originally to run large numerical computations Accepts data in the form of multidimensional arrays of higher dimensions called Tensors 2 8 1 7 5 Nodes Edges
  • 13. What is TensorFlow? Works on the basis of Data Flow graphs that have nodes and edges Open source library developed by Google Developed originally to run large numerical computations Accepts data in the form of multidimensional arrays of higher dimensions called Tensors 2 8 1 7 5 Nodes Edges
  • 14. What is TensorFlow? Works on the basis of Data Flow graphs that have nodes and edges Open source library developed by Google Developed originally to run large numerical computations Accepts data in the form of multidimensional arrays of higher dimensions called Tensors 2 8 1 7 5 Nodes Edges
  • 15. What are 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. Tensors 3 2 8 1 2 5 5 1 4 6 4 9 3 2 7 Data in the form of arrays is fed as input to the network Input Layer Hidden Layers Output Layer
  • 16. What are Tensors? Tensors a m k q d Tensor of Dimensions[5]Different Dimensions 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.
  • 17. What are Tensors? Tensors 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]Different Dimensions 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.
  • 18. What are Tensors? Tensors Different Dimensions Tensor of Dimensions[3,3,3] 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.
  • 20. What is a Data Flow graph? Source: TensorFlow website 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
  • 21. Program Elements in TensorFlow TensorFlow programs work on two basic concept Building a computational graph Executing a computational graph Step 2 Step 1
  • 22. Program 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)
  • 23. Program 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
  • 24. Program Elements in TensorFlow Variable 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
  • 25. Program Elements in TensorFlow Session A session is run to evaluate the nodes. This is called as the TensorFlow runtime. Example: a = tf.constant(5.0) b = tf.constant(3.0) c = a*b # Launch Session sess = tf.Session() # Evaluate the tensor c print(sess.run(c)) 5.0 3.0 15.0 Multiplication Running a Computation Graph
  • 29. TensorFlow program basics Performing Computations using TensorFlow
  • 30. TensorFlow program basics Matrix Multiplication using TensorFlow
  • 32. 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 race relationship occupation gender workclass education education_num hours_per_week capital_loss capital_gain income_bracket native_country Predict Income
  • 33. Use case Implementation using TensorFlow 1. Read the census_data.csv using pandas library 2. Display the head of the dataset
  • 34. 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
  • 35. 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
  • 36. 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
  • 37. Use case Implementation using TensorFlow 10. Train the model for at least 5000 steps 11. Evaluation of the model
  • 38. 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

Editor's Notes