Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Introduction to TensorFlow
Portland Data Science Group
Created by Andrew Ferlitsch
Community Outreach
June, 2017
What is it?
An Open Source Machine Learning Library released by Google in 2015
• Built on top of Google’s Inception v3
• Google’s most advanced image recognition system
• Convolution Neural Network (CNN)
• Available as a Python (or C++) Library
Basics – What is a Vector?
Vector = [ number, number, … ]
• A vector is an array of numbers.
• In machine learning, a vector holds the feature
values (variables) for a sample.
24 16 5 120000Vector =
Age Education
Level
Years of
Experience
Income
Basics – What is a Matrix?
Matrix = [ n ][ m ]
• A matrix is a 2-dimensional array of numbers.
• In machine learning, a matrix holds the feature
values [columns] for samples [rows] in a dataset.
24 16 5 120000
27 12 8 70000
28 18 2 135000
Matrix =
Age Education
Level
Years of
Experience
Income
What is a Tensor?
Tensor = [ n1 ][ n2 ] … [ nx ]
• A tensor is a high dimensional array.
• A tensor consists of features, where each feature
is a vector or multi-dimensional array (e.g., such
as in embedding).
A Sample
1
2
3
4
5
6
7
8
9
Features
Design & Run
• TensorFlow uses a Design & Run methodology.
Design
(symbolic representation)
Run
(bind the data and execute)
Construct training model
symbolically.
Once designed, bind (connect)
the data and execute the
model.
Data
Output
Symbolic Representation as Graph
• Tensors are inputs to tensor operations, which
output new tensors.
Variable
(tensor)
Variable
(tensor)
Op
Output
(tensor)
User constructs a symbolic representation (graph)
of how tensors flow through the network.
A Simple TensorFlow Graph
Variable
(matrix)
Variable
(matrix)
MatMul
Output
(matrix)
Two matrices
are defined as
input.
The two matrices
are dot multiplied.
The output is the dot
product of the two matrices.
TensorFlow with Python - Constants
import tensorflow as tf # import the Tensorflow library
x1 = tf.constant( 1.0 ) # define some constants
x2 = tf.constant( 2.0 )
By default, values are
floating point numbers
sess = tf.session() # connect session for execution
sess.run( [x1, x2] ) # run the graph
• Design the Graph
• Run the Graph
[ 1.0, 2.0 ]
TensorFlow with Python - Operations
import tensorflow as tf # import the tensorflow library
x1 = tf.constant( 1.0 ) # define some constants
x2 = tf.constant( 2.0 )
x3 = tf.add( x1, x2 ) # add inputs x1 and x2
sess = tf.session() # connect session for execution
sess.run( x3 ) # run the graph
• Design the Graph
• Run the Graph
3.0
When node x3 is executed, it takes the inputs x1 and x2
and applies the tensor add operation. Since these are scalar
values, they are added together to output a new scalar value.
TensorFlow with Python - Placeholders
import tensorflow as tf # import the Tensorflow library
x1 = tf.placeholder( tf.float ) # define some placeholders
x2 = tf.placeholder( tf.float )
x3 = tf.add( x1, x2 ) # add inputs x1 and x2
sess = tf.session() # connect session for execution
sess.run( x3, {x1: 1.0, x2: 2.0} ) # run the graph
• Design the Graph
• Run the Graph
3.0
When node x3 is executed, it binds the values to the inputs x1 and x2
and applies the tensor add operation. Since these are scalar
values, they are added together to output a new scalar value.
The data is bound at run time (parameterized variables).
TensorFlow with Python - Binding
import tensorflow as tf # import the Tensorflow library
x1 = tf.placeholder( tf.float, shape=[2] ) # define some placeholders
x2 = tf.placeholder( tf.float, shape=[2] )
x3 = tf.add( x1, x2 ) # add inputs x1 and x2
sess = tf.session() # connect session for execution
sess.run( x3, {x1: [1.0,2.0], x2: [3.0,4.0]} ) # run the graph
• Design the Graph
• Run the Graph
[ 4.0, 6.0 ]
Bound an array instead of a scalar value
Matrix addition
Multiple Operation TensorFlow Graph
Variable
(matrix)
Variable
(matrix)
MatAdd MatMul
The two matrices
are added.
The output is the dot
product (weight) of the addition of
the two matrices.
Output
(matrix)
Constant
(Scalar)
Weight applied to
operation.
TensorFlow with Python – Multi-Op
import tensorflow as tf # import the Tensorflow library
x1 = tf.placeholder( tf.float ) # define some placeholders
x2 = tf.placeholder( tf.float )
x3 = tf.add( x1, x2 ) # add inputs x1 and x2
x4 = tf.muliply( x3, 3.0 ) # multiply the result by 3
sess = tf.session() # connect session for execution
sess.run( x4, {x1: [1.0,2.0], x2: [3.0,4.0]} ) # run the graph
• Design the Graph
• Run the Graph
[ 12.0, 18.0 ]
Matrix multiply (weight) applied to Matrix addition
TensorFlow with Python – Operators
import tensorflow as tf # import the Tensorflow library
x1 = tf.placeholder( tf.float, shape=[2] ) # define some variables
x2 = tf.placeholder( tf.float, shape=[2] )
x3 = x1 + x2 # add inputs x1 and x2
x4 = x3 * 3.0 # multiply the result by 3
sess = tf.session() # connect session for execution
sess.run( x4, {x1: [1.0,2.0], x2: [3.0,4.0]} ) # run the graph
• Design the Graph
• Run the Graph
[ 12.0, 18.0 ]
Shortcut (or inline) operator
TensorFlow with Python – Variables
import tensorflow as tf # import the Tensorflow library
a = tf.Variable( tf.float ) # define some variables
b = tf.Variable( tf.float )
x = tf.placeholder( tf.float, shape=[4] )
yhat = a + b * x # simple linear regression
sess = tf.session() # connect session for execution
init = tf_global_variables_initializer() # initialize global variables
sess.run(init)
sess.run( yhat, {x: [1,2,3,4]} ) # run the graph
• Design the Graph
• Run the Graph
[ 0, 0.30000001, 0.60000001, 0.90000001 ]
Variables must be explicitly initialized
prior to running the graph
Run simple linear regression for x = 1, 2, 3 and 4
Example from tensorflow.org
TensorFlow with Python – Loss Function
y = tf.placeholder( tf.float ) # labels (actual values)
squares = tf.square( yhat – y ) # square of error
loss = tf.reduce_sum( squares ) # summation of squared errors
sess = tf.session() # connect session for execution
init = tf_global_variables_initializer() # initialize global variables
sess.run(init)
sess.run( loss, {x: [1,2,3,4], y:[0,-1,-2,-3]} ) # execute the graph
• Design the Graph
• Run the Graph
23.66
Sum up the squared difference of the actual
and predicted values.
Run simple linear regression for x = 1, 2, 3 and 4
with actual values 0, -1, -2 and -3.
Example from tensorflow.org
TensorFlow with Python – tf.train
optimizer = tf.train.GradientDescentOptimizer( 0.1 )
train = optimizer.minimize( loss ) # training model
sess.run(init)
for i in range(0,1000): # train over 1000 iterations
sess.run( train, {x: [1,2,3,4], y:[0,-1,-2,-3]} ) # train the model
sess.run([ b,w ] )
• Design the Graph
• Run the Graph
[0.99999082, -0.9999969]
Learning rate
Train the simple linear regression over 1000 iterations
to minimize the loss function.
Example from tensorflow.org
TensorFlow and tf.contrib.learn
• Not Covered in this tutorial
• Is a high-level wrapper built on top of Tensorflow
• For Developers – hides low-level implementation
tf.contrib.learn is a high-level TensorFlow library that
simplifies the mechanics of machine learning, including the
following:
• running training loops
• running evaluation loops
• managing data sets
• managing feeding
From tensorflow.org

More Related Content

What's hot

Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)
Appsilon Data Science
 
Introduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkIntroduction to Recurrent Neural Network
Introduction to Recurrent Neural Network
Yan Xu
 
Deep Learning - A Literature survey
Deep Learning - A Literature surveyDeep Learning - A Literature survey
Deep Learning - A Literature survey
Akshay Hegde
 
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
Fellowship at Vodafone FutureLab
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
Sungjoon Choi
 
深層学習入門
深層学習入門深層学習入門
深層学習入門
Danushka Bollegala
 
Physics-Informed Machine Learning
Physics-Informed Machine LearningPhysics-Informed Machine Learning
Physics-Informed Machine Learning
OmarYounis21
 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep Learning
Oswald Campesato
 
“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...
“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...
“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...
Edge AI and Vision Alliance
 
PhD Defense
PhD DefensePhD Defense
PhD Defense
Taehoon Lee
 
Machine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dkuMachine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dku
Seokhyun Yoon
 
Deep learning with Keras
Deep learning with KerasDeep learning with Keras
Deep learning with Keras
QuantUniversity
 
Yolov3
Yolov3Yolov3
Yolov3
SHREY MOHAN
 
Attention is All You Need (Transformer)
Attention is All You Need (Transformer)Attention is All You Need (Transformer)
Attention is All You Need (Transformer)
Jeong-Gwan Lee
 
PR 127: FaceNet
PR 127: FaceNetPR 127: FaceNet
PR 127: FaceNet
Taeoh Kim
 
Focal loss for dense object detection
Focal loss for dense object detectionFocal loss for dense object detection
Focal loss for dense object detection
DaeHeeKim31
 
Introduction to Deep Learning (NVIDIA)
Introduction to Deep Learning (NVIDIA)Introduction to Deep Learning (NVIDIA)
Introduction to Deep Learning (NVIDIA)
Rakuten Group, Inc.
 
Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...
Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...
Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...
Ryo Takahashi
 
Transfer Learning and Fine-tuning Deep Neural Networks
 Transfer Learning and Fine-tuning Deep Neural Networks Transfer Learning and Fine-tuning Deep Neural Networks
Transfer Learning and Fine-tuning Deep Neural Networks
PyData
 
Matrix and Tensor Tools for Computer Vision
Matrix and Tensor Tools for Computer VisionMatrix and Tensor Tools for Computer Vision
Matrix and Tensor Tools for Computer Vision
ActiveEon
 

What's hot (20)

Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)
 
Introduction to Recurrent Neural Network
Introduction to Recurrent Neural NetworkIntroduction to Recurrent Neural Network
Introduction to Recurrent Neural Network
 
Deep Learning - A Literature survey
Deep Learning - A Literature surveyDeep Learning - A Literature survey
Deep Learning - A Literature survey
 
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
 
深層学習入門
深層学習入門深層学習入門
深層学習入門
 
Physics-Informed Machine Learning
Physics-Informed Machine LearningPhysics-Informed Machine Learning
Physics-Informed Machine Learning
 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep Learning
 
“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...
“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...
“An Introduction to Data Augmentation Techniques in ML Frameworks,” a Present...
 
PhD Defense
PhD DefensePhD Defense
PhD Defense
 
Machine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dkuMachine learning and_neural_network_lecture_slide_ece_dku
Machine learning and_neural_network_lecture_slide_ece_dku
 
Deep learning with Keras
Deep learning with KerasDeep learning with Keras
Deep learning with Keras
 
Yolov3
Yolov3Yolov3
Yolov3
 
Attention is All You Need (Transformer)
Attention is All You Need (Transformer)Attention is All You Need (Transformer)
Attention is All You Need (Transformer)
 
PR 127: FaceNet
PR 127: FaceNetPR 127: FaceNet
PR 127: FaceNet
 
Focal loss for dense object detection
Focal loss for dense object detectionFocal loss for dense object detection
Focal loss for dense object detection
 
Introduction to Deep Learning (NVIDIA)
Introduction to Deep Learning (NVIDIA)Introduction to Deep Learning (NVIDIA)
Introduction to Deep Learning (NVIDIA)
 
Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...
Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...
Quantization and Training of Neural Networks for Efficient Integer-Arithmetic...
 
Transfer Learning and Fine-tuning Deep Neural Networks
 Transfer Learning and Fine-tuning Deep Neural Networks Transfer Learning and Fine-tuning Deep Neural Networks
Transfer Learning and Fine-tuning Deep Neural Networks
 
Matrix and Tensor Tools for Computer Vision
Matrix and Tensor Tools for Computer VisionMatrix and Tensor Tools for Computer Vision
Matrix and Tensor Tools for Computer Vision
 

Similar to Machine Learning - Introduction to Tensorflow

Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016
Chris Fregly
 
TensorFlow Tutorial.pdf
TensorFlow Tutorial.pdfTensorFlow Tutorial.pdf
TensorFlow Tutorial.pdf
Antonio Espinosa
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
Oswald Campesato
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
Oswald Campesato
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
Ashish Bansal
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016
Andrii Babii
 
Google TensorFlow Tutorial
Google TensorFlow TutorialGoogle TensorFlow Tutorial
Google TensorFlow Tutorial
台灣資料科學年會
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
Oswald Campesato
 
Introduction to TensorFlow
Introduction to TensorFlowIntroduction to TensorFlow
Introduction to TensorFlow
Babu Priyavrat
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
Oswald Campesato
 
Introduction To Using TensorFlow & Deep Learning
Introduction To Using TensorFlow & Deep LearningIntroduction To Using TensorFlow & Deep Learning
Introduction To Using TensorFlow & Deep Learning
ali alemi
 
Tensorflow - Intro (2017)
Tensorflow - Intro (2017)Tensorflow - Intro (2017)
Tensorflow - Intro (2017)
Alessio Tonioni
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
Oswald Campesato
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
Mark Chang
 
Meetup tensorframes
Meetup tensorframesMeetup tensorframes
Meetup tensorframes
Paolo Platter
 
A Tour of Tensorflow's APIs
A Tour of Tensorflow's APIsA Tour of Tensorflow's APIs
A Tour of Tensorflow's APIs
Dean Wyatte
 
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC.im(Notch Training Center)
 
TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習
Mark Chang
 
Theano vs TensorFlow | Edureka
Theano vs TensorFlow | EdurekaTheano vs TensorFlow | Edureka
Theano vs TensorFlow | Edureka
Edureka!
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
Oswald Campesato
 

Similar to Machine Learning - Introduction to Tensorflow (20)

Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016
 
TensorFlow Tutorial.pdf
TensorFlow Tutorial.pdfTensorFlow Tutorial.pdf
TensorFlow Tutorial.pdf
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016
 
Google TensorFlow Tutorial
Google TensorFlow TutorialGoogle TensorFlow Tutorial
Google TensorFlow Tutorial
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
 
Introduction to TensorFlow
Introduction to TensorFlowIntroduction to TensorFlow
Introduction to TensorFlow
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
 
Introduction To Using TensorFlow & Deep Learning
Introduction To Using TensorFlow & Deep LearningIntroduction To Using TensorFlow & Deep Learning
Introduction To Using TensorFlow & Deep Learning
 
Tensorflow - Intro (2017)
Tensorflow - Intro (2017)Tensorflow - Intro (2017)
Tensorflow - Intro (2017)
 
Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
 
NTU ML TENSORFLOW
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
 
Meetup tensorframes
Meetup tensorframesMeetup tensorframes
Meetup tensorframes
 
A Tour of Tensorflow's APIs
A Tour of Tensorflow's APIsA Tour of Tensorflow's APIs
A Tour of Tensorflow's APIs
 
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
 
TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習
 
Theano vs TensorFlow | Edureka
Theano vs TensorFlow | EdurekaTheano vs TensorFlow | Edureka
Theano vs TensorFlow | Edureka
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
 

More from Andrew Ferlitsch

AI - Intelligent Agents
AI - Intelligent AgentsAI - Intelligent Agents
AI - Intelligent Agents
Andrew Ferlitsch
 
Pareto Principle Applied to QA
Pareto Principle Applied to QAPareto Principle Applied to QA
Pareto Principle Applied to QA
Andrew Ferlitsch
 
Whiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in Python
Andrew Ferlitsch
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
Andrew Ferlitsch
 
Python - OOP Programming
Python - OOP ProgrammingPython - OOP Programming
Python - OOP Programming
Andrew Ferlitsch
 
Python - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter NotepadPython - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter Notepad
Andrew Ferlitsch
 
Natural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) GenerationNatural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) Generation
Andrew Ferlitsch
 
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
Andrew Ferlitsch
 
Machine Learning - Introduction to Recurrent Neural Networks
Machine Learning - Introduction to Recurrent Neural NetworksMachine Learning - Introduction to Recurrent Neural Networks
Machine Learning - Introduction to Recurrent Neural Networks
Andrew Ferlitsch
 
Machine Learning - Introduction to Convolutional Neural Networks
Machine Learning - Introduction to Convolutional Neural NetworksMachine Learning - Introduction to Convolutional Neural Networks
Machine Learning - Introduction to Convolutional Neural Networks
Andrew Ferlitsch
 
Machine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural NetworksMachine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural Networks
Andrew Ferlitsch
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Andrew Ferlitsch
 
Machine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion MatrixMachine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion Matrix
Andrew Ferlitsch
 
Machine Learning - Ensemble Methods
Machine Learning - Ensemble MethodsMachine Learning - Ensemble Methods
Machine Learning - Ensemble Methods
Andrew Ferlitsch
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear Regression
Andrew Ferlitsch
 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
Andrew Ferlitsch
 
Machine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable ConversionMachine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable Conversion
Andrew Ferlitsch
 
Machine Learning - Splitting Datasets
Machine Learning - Splitting DatasetsMachine Learning - Splitting Datasets
Machine Learning - Splitting Datasets
Andrew Ferlitsch
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
Andrew Ferlitsch
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
Andrew Ferlitsch
 

More from Andrew Ferlitsch (20)

AI - Intelligent Agents
AI - Intelligent AgentsAI - Intelligent Agents
AI - Intelligent Agents
 
Pareto Principle Applied to QA
Pareto Principle Applied to QAPareto Principle Applied to QA
Pareto Principle Applied to QA
 
Whiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in Python
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
 
Python - OOP Programming
Python - OOP ProgrammingPython - OOP Programming
Python - OOP Programming
 
Python - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter NotepadPython - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter Notepad
 
Natural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) GenerationNatural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) Generation
 
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class...
 
Machine Learning - Introduction to Recurrent Neural Networks
Machine Learning - Introduction to Recurrent Neural NetworksMachine Learning - Introduction to Recurrent Neural Networks
Machine Learning - Introduction to Recurrent Neural Networks
 
Machine Learning - Introduction to Convolutional Neural Networks
Machine Learning - Introduction to Convolutional Neural NetworksMachine Learning - Introduction to Convolutional Neural Networks
Machine Learning - Introduction to Convolutional Neural Networks
 
Machine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural NetworksMachine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural Networks
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
Machine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion MatrixMachine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion Matrix
 
Machine Learning - Ensemble Methods
Machine Learning - Ensemble MethodsMachine Learning - Ensemble Methods
Machine Learning - Ensemble Methods
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear Regression
 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
 
Machine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable ConversionMachine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable Conversion
 
Machine Learning - Splitting Datasets
Machine Learning - Splitting DatasetsMachine Learning - Splitting Datasets
Machine Learning - Splitting Datasets
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 

Recently uploaded

Network Auto Configuration and Correction using Python.pptx
Network Auto Configuration and Correction using Python.pptxNetwork Auto Configuration and Correction using Python.pptx
Network Auto Configuration and Correction using Python.pptx
saikumaresh2
 
Webinar: Transforming Substation Automation with Open Source Solutions
Webinar: Transforming Substation Automation with Open Source SolutionsWebinar: Transforming Substation Automation with Open Source Solutions
Webinar: Transforming Substation Automation with Open Source Solutions
DanBrown980551
 
Understanding NFT Marketplace Ecosystem.pptx
Understanding  NFT Marketplace Ecosystem.pptxUnderstanding  NFT Marketplace Ecosystem.pptx
Understanding NFT Marketplace Ecosystem.pptx
NFT Space.
 
How CXAI Toolkit uses RAG for Intelligent Q&A
How CXAI Toolkit uses RAG for Intelligent Q&AHow CXAI Toolkit uses RAG for Intelligent Q&A
How CXAI Toolkit uses RAG for Intelligent Q&A
Zilliz
 
Informatika smk kelas 10 kurikulum merdeka.pptx
Informatika smk kelas 10 kurikulum merdeka.pptxInformatika smk kelas 10 kurikulum merdeka.pptx
Informatika smk kelas 10 kurikulum merdeka.pptx
OkyPrayudi
 
TribeQonf2024_Dimpy_ShiftingSecurityLeft
TribeQonf2024_Dimpy_ShiftingSecurityLeftTribeQonf2024_Dimpy_ShiftingSecurityLeft
TribeQonf2024_Dimpy_ShiftingSecurityLeft
Dimpy Adhikary
 
Scientific-Based Blockchain TON Project Analysis Report
Scientific-Based Blockchain  TON Project Analysis ReportScientific-Based Blockchain  TON Project Analysis Report
Scientific-Based Blockchain TON Project Analysis Report
SelcukTOPAL2
 
Global Collaboration for Space Exploration.pdf
Global Collaboration for Space Exploration.pdfGlobal Collaboration for Space Exploration.pdf
Global Collaboration for Space Exploration.pdf
Sachin Chitre
 
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptxFIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Alliance
 
FIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptxFIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Alliance
 
Flame Atomic Emission Spectroscopy.-pptx
Flame Atomic Emission Spectroscopy.-pptxFlame Atomic Emission Spectroscopy.-pptx
Flame Atomic Emission Spectroscopy.-pptx
VaishnaviChavan206944
 
STKI Israeli IT Market Study v2 August 2024.pdf
STKI Israeli IT Market Study v2 August 2024.pdfSTKI Israeli IT Market Study v2 August 2024.pdf
STKI Israeli IT Market Study v2 August 2024.pdf
Dr. Jimmy Schwarzkopf
 
Project Delivery Methodology on a page with activities, deliverables
Project Delivery Methodology on a page with activities, deliverablesProject Delivery Methodology on a page with activities, deliverables
Project Delivery Methodology on a page with activities, deliverables
CLIVE MINCHIN
 
Securiport Gambia - Intelligent Threat Analysis
Securiport Gambia - Intelligent Threat AnalysisSecuriport Gambia - Intelligent Threat Analysis
Securiport Gambia - Intelligent Threat Analysis
Securiport Gambia
 
UiPath Community Day Amsterdam presentations
UiPath Community Day Amsterdam presentationsUiPath Community Day Amsterdam presentations
UiPath Community Day Amsterdam presentations
UiPathCommunity
 
The Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdfThe Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdf
Sara Kroft
 
UiPath Community Day Amsterdam: Code, Collaborate, Connect
UiPath Community Day Amsterdam: Code, Collaborate, ConnectUiPath Community Day Amsterdam: Code, Collaborate, Connect
UiPath Community Day Amsterdam: Code, Collaborate, Connect
UiPathCommunity
 
Blue Screen Of Death | Windows Down | Biggest IT failure
Blue Screen Of Death | Windows Down | Biggest IT failureBlue Screen Of Death | Windows Down | Biggest IT failure
Blue Screen Of Death | Windows Down | Biggest IT failure
Dexbytes Infotech Pvt Ltd
 
Best USA IPTV Providers to Stream in 2024.pdf
Best USA IPTV Providers to Stream in 2024.pdfBest USA IPTV Providers to Stream in 2024.pdf
Best USA IPTV Providers to Stream in 2024.pdf
perth Riya
 
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptxFIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Alliance
 

Recently uploaded (20)

Network Auto Configuration and Correction using Python.pptx
Network Auto Configuration and Correction using Python.pptxNetwork Auto Configuration and Correction using Python.pptx
Network Auto Configuration and Correction using Python.pptx
 
Webinar: Transforming Substation Automation with Open Source Solutions
Webinar: Transforming Substation Automation with Open Source SolutionsWebinar: Transforming Substation Automation with Open Source Solutions
Webinar: Transforming Substation Automation with Open Source Solutions
 
Understanding NFT Marketplace Ecosystem.pptx
Understanding  NFT Marketplace Ecosystem.pptxUnderstanding  NFT Marketplace Ecosystem.pptx
Understanding NFT Marketplace Ecosystem.pptx
 
How CXAI Toolkit uses RAG for Intelligent Q&A
How CXAI Toolkit uses RAG for Intelligent Q&AHow CXAI Toolkit uses RAG for Intelligent Q&A
How CXAI Toolkit uses RAG for Intelligent Q&A
 
Informatika smk kelas 10 kurikulum merdeka.pptx
Informatika smk kelas 10 kurikulum merdeka.pptxInformatika smk kelas 10 kurikulum merdeka.pptx
Informatika smk kelas 10 kurikulum merdeka.pptx
 
TribeQonf2024_Dimpy_ShiftingSecurityLeft
TribeQonf2024_Dimpy_ShiftingSecurityLeftTribeQonf2024_Dimpy_ShiftingSecurityLeft
TribeQonf2024_Dimpy_ShiftingSecurityLeft
 
Scientific-Based Blockchain TON Project Analysis Report
Scientific-Based Blockchain  TON Project Analysis ReportScientific-Based Blockchain  TON Project Analysis Report
Scientific-Based Blockchain TON Project Analysis Report
 
Global Collaboration for Space Exploration.pdf
Global Collaboration for Space Exploration.pdfGlobal Collaboration for Space Exploration.pdf
Global Collaboration for Space Exploration.pdf
 
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptxFIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
FIDO Munich Seminar: Strong Workforce Authn Push & Pull Factors.pptx
 
FIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptxFIDO Munich Seminar: FIDO Tech Principles.pptx
FIDO Munich Seminar: FIDO Tech Principles.pptx
 
Flame Atomic Emission Spectroscopy.-pptx
Flame Atomic Emission Spectroscopy.-pptxFlame Atomic Emission Spectroscopy.-pptx
Flame Atomic Emission Spectroscopy.-pptx
 
STKI Israeli IT Market Study v2 August 2024.pdf
STKI Israeli IT Market Study v2 August 2024.pdfSTKI Israeli IT Market Study v2 August 2024.pdf
STKI Israeli IT Market Study v2 August 2024.pdf
 
Project Delivery Methodology on a page with activities, deliverables
Project Delivery Methodology on a page with activities, deliverablesProject Delivery Methodology on a page with activities, deliverables
Project Delivery Methodology on a page with activities, deliverables
 
Securiport Gambia - Intelligent Threat Analysis
Securiport Gambia - Intelligent Threat AnalysisSecuriport Gambia - Intelligent Threat Analysis
Securiport Gambia - Intelligent Threat Analysis
 
UiPath Community Day Amsterdam presentations
UiPath Community Day Amsterdam presentationsUiPath Community Day Amsterdam presentations
UiPath Community Day Amsterdam presentations
 
The Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdfThe Challenge of Interpretability in Generative AI Models.pdf
The Challenge of Interpretability in Generative AI Models.pdf
 
UiPath Community Day Amsterdam: Code, Collaborate, Connect
UiPath Community Day Amsterdam: Code, Collaborate, ConnectUiPath Community Day Amsterdam: Code, Collaborate, Connect
UiPath Community Day Amsterdam: Code, Collaborate, Connect
 
Blue Screen Of Death | Windows Down | Biggest IT failure
Blue Screen Of Death | Windows Down | Biggest IT failureBlue Screen Of Death | Windows Down | Biggest IT failure
Blue Screen Of Death | Windows Down | Biggest IT failure
 
Best USA IPTV Providers to Stream in 2024.pdf
Best USA IPTV Providers to Stream in 2024.pdfBest USA IPTV Providers to Stream in 2024.pdf
Best USA IPTV Providers to Stream in 2024.pdf
 
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptxFIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
FIDO Munich Seminar: Biometrics and Passkeys for In-Vehicle Apps.pptx
 

Machine Learning - Introduction to Tensorflow

  • 1. Introduction to TensorFlow Portland Data Science Group Created by Andrew Ferlitsch Community Outreach June, 2017
  • 2. What is it? An Open Source Machine Learning Library released by Google in 2015 • Built on top of Google’s Inception v3 • Google’s most advanced image recognition system • Convolution Neural Network (CNN) • Available as a Python (or C++) Library
  • 3. Basics – What is a Vector? Vector = [ number, number, … ] • A vector is an array of numbers. • In machine learning, a vector holds the feature values (variables) for a sample. 24 16 5 120000Vector = Age Education Level Years of Experience Income
  • 4. Basics – What is a Matrix? Matrix = [ n ][ m ] • A matrix is a 2-dimensional array of numbers. • In machine learning, a matrix holds the feature values [columns] for samples [rows] in a dataset. 24 16 5 120000 27 12 8 70000 28 18 2 135000 Matrix = Age Education Level Years of Experience Income
  • 5. What is a Tensor? Tensor = [ n1 ][ n2 ] … [ nx ] • A tensor is a high dimensional array. • A tensor consists of features, where each feature is a vector or multi-dimensional array (e.g., such as in embedding). A Sample 1 2 3 4 5 6 7 8 9 Features
  • 6. Design & Run • TensorFlow uses a Design & Run methodology. Design (symbolic representation) Run (bind the data and execute) Construct training model symbolically. Once designed, bind (connect) the data and execute the model. Data Output
  • 7. Symbolic Representation as Graph • Tensors are inputs to tensor operations, which output new tensors. Variable (tensor) Variable (tensor) Op Output (tensor) User constructs a symbolic representation (graph) of how tensors flow through the network.
  • 8. A Simple TensorFlow Graph Variable (matrix) Variable (matrix) MatMul Output (matrix) Two matrices are defined as input. The two matrices are dot multiplied. The output is the dot product of the two matrices.
  • 9. TensorFlow with Python - Constants import tensorflow as tf # import the Tensorflow library x1 = tf.constant( 1.0 ) # define some constants x2 = tf.constant( 2.0 ) By default, values are floating point numbers sess = tf.session() # connect session for execution sess.run( [x1, x2] ) # run the graph • Design the Graph • Run the Graph [ 1.0, 2.0 ]
  • 10. TensorFlow with Python - Operations import tensorflow as tf # import the tensorflow library x1 = tf.constant( 1.0 ) # define some constants x2 = tf.constant( 2.0 ) x3 = tf.add( x1, x2 ) # add inputs x1 and x2 sess = tf.session() # connect session for execution sess.run( x3 ) # run the graph • Design the Graph • Run the Graph 3.0 When node x3 is executed, it takes the inputs x1 and x2 and applies the tensor add operation. Since these are scalar values, they are added together to output a new scalar value.
  • 11. TensorFlow with Python - Placeholders import tensorflow as tf # import the Tensorflow library x1 = tf.placeholder( tf.float ) # define some placeholders x2 = tf.placeholder( tf.float ) x3 = tf.add( x1, x2 ) # add inputs x1 and x2 sess = tf.session() # connect session for execution sess.run( x3, {x1: 1.0, x2: 2.0} ) # run the graph • Design the Graph • Run the Graph 3.0 When node x3 is executed, it binds the values to the inputs x1 and x2 and applies the tensor add operation. Since these are scalar values, they are added together to output a new scalar value. The data is bound at run time (parameterized variables).
  • 12. TensorFlow with Python - Binding import tensorflow as tf # import the Tensorflow library x1 = tf.placeholder( tf.float, shape=[2] ) # define some placeholders x2 = tf.placeholder( tf.float, shape=[2] ) x3 = tf.add( x1, x2 ) # add inputs x1 and x2 sess = tf.session() # connect session for execution sess.run( x3, {x1: [1.0,2.0], x2: [3.0,4.0]} ) # run the graph • Design the Graph • Run the Graph [ 4.0, 6.0 ] Bound an array instead of a scalar value Matrix addition
  • 13. Multiple Operation TensorFlow Graph Variable (matrix) Variable (matrix) MatAdd MatMul The two matrices are added. The output is the dot product (weight) of the addition of the two matrices. Output (matrix) Constant (Scalar) Weight applied to operation.
  • 14. TensorFlow with Python – Multi-Op import tensorflow as tf # import the Tensorflow library x1 = tf.placeholder( tf.float ) # define some placeholders x2 = tf.placeholder( tf.float ) x3 = tf.add( x1, x2 ) # add inputs x1 and x2 x4 = tf.muliply( x3, 3.0 ) # multiply the result by 3 sess = tf.session() # connect session for execution sess.run( x4, {x1: [1.0,2.0], x2: [3.0,4.0]} ) # run the graph • Design the Graph • Run the Graph [ 12.0, 18.0 ] Matrix multiply (weight) applied to Matrix addition
  • 15. TensorFlow with Python – Operators import tensorflow as tf # import the Tensorflow library x1 = tf.placeholder( tf.float, shape=[2] ) # define some variables x2 = tf.placeholder( tf.float, shape=[2] ) x3 = x1 + x2 # add inputs x1 and x2 x4 = x3 * 3.0 # multiply the result by 3 sess = tf.session() # connect session for execution sess.run( x4, {x1: [1.0,2.0], x2: [3.0,4.0]} ) # run the graph • Design the Graph • Run the Graph [ 12.0, 18.0 ] Shortcut (or inline) operator
  • 16. TensorFlow with Python – Variables import tensorflow as tf # import the Tensorflow library a = tf.Variable( tf.float ) # define some variables b = tf.Variable( tf.float ) x = tf.placeholder( tf.float, shape=[4] ) yhat = a + b * x # simple linear regression sess = tf.session() # connect session for execution init = tf_global_variables_initializer() # initialize global variables sess.run(init) sess.run( yhat, {x: [1,2,3,4]} ) # run the graph • Design the Graph • Run the Graph [ 0, 0.30000001, 0.60000001, 0.90000001 ] Variables must be explicitly initialized prior to running the graph Run simple linear regression for x = 1, 2, 3 and 4 Example from tensorflow.org
  • 17. TensorFlow with Python – Loss Function y = tf.placeholder( tf.float ) # labels (actual values) squares = tf.square( yhat – y ) # square of error loss = tf.reduce_sum( squares ) # summation of squared errors sess = tf.session() # connect session for execution init = tf_global_variables_initializer() # initialize global variables sess.run(init) sess.run( loss, {x: [1,2,3,4], y:[0,-1,-2,-3]} ) # execute the graph • Design the Graph • Run the Graph 23.66 Sum up the squared difference of the actual and predicted values. Run simple linear regression for x = 1, 2, 3 and 4 with actual values 0, -1, -2 and -3. Example from tensorflow.org
  • 18. TensorFlow with Python – tf.train optimizer = tf.train.GradientDescentOptimizer( 0.1 ) train = optimizer.minimize( loss ) # training model sess.run(init) for i in range(0,1000): # train over 1000 iterations sess.run( train, {x: [1,2,3,4], y:[0,-1,-2,-3]} ) # train the model sess.run([ b,w ] ) • Design the Graph • Run the Graph [0.99999082, -0.9999969] Learning rate Train the simple linear regression over 1000 iterations to minimize the loss function. Example from tensorflow.org
  • 19. TensorFlow and tf.contrib.learn • Not Covered in this tutorial • Is a high-level wrapper built on top of Tensorflow • For Developers – hides low-level implementation tf.contrib.learn is a high-level TensorFlow library that simplifies the mechanics of machine learning, including the following: • running training loops • running evaluation loops • managing data sets • managing feeding From tensorflow.org