SlideShare ist ein Scribd-Unternehmen logo
1 von 19
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

Weitere ähnliche Inhalte

Was ist angesagt?

Supervised learning
Supervised learningSupervised learning
Supervised learningankit_ppt
 
Training Neural Networks
Training Neural NetworksTraining Neural Networks
Training Neural NetworksDatabricks
 
Machine Learning - Splitting Datasets
Machine Learning - Splitting DatasetsMachine Learning - Splitting Datasets
Machine Learning - Splitting DatasetsAndrew Ferlitsch
 
Types of machine learning
Types of machine learningTypes of machine learning
Types of machine learningHimaniAloona
 
Sentiment Analysis
Sentiment AnalysisSentiment Analysis
Sentiment AnalysisDinesh V
 
Deep Learning - Overview of my work II
Deep Learning - Overview of my work IIDeep Learning - Overview of my work II
Deep Learning - Overview of my work IIMohamed Loey
 
Machine learning vs deep learning
Machine learning vs deep learningMachine learning vs deep learning
Machine learning vs deep learningUSM Systems
 
Introduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisIntroduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisJaclyn Kokx
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowSri Ambati
 
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...PyData
 
Recurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRURecurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRUananth
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset PreparationAndrew Ferlitsch
 
Lasso and ridge regression
Lasso and ridge regressionLasso and ridge regression
Lasso and ridge regressionSreerajVA
 
What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...
What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...
What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...Simplilearn
 
forestFloorパッケージを使ったrandomForestの感度分析
forestFloorパッケージを使ったrandomForestの感度分析forestFloorパッケージを使ったrandomForestの感度分析
forestFloorパッケージを使ったrandomForestの感度分析Satoshi Kato
 
Machine Learning presentation.
Machine Learning presentation.Machine Learning presentation.
Machine Learning presentation.butest
 
Introduction to Autoencoders
Introduction to AutoencodersIntroduction to Autoencoders
Introduction to AutoencodersYan Xu
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality ReductionKnoldus Inc.
 

Was ist angesagt? (20)

Supervised learning
Supervised learningSupervised learning
Supervised learning
 
Training Neural Networks
Training Neural NetworksTraining Neural Networks
Training Neural Networks
 
Machine Learning - Splitting Datasets
Machine Learning - Splitting DatasetsMachine Learning - Splitting Datasets
Machine Learning - Splitting Datasets
 
Types of machine learning
Types of machine learningTypes of machine learning
Types of machine learning
 
svm.pptx
svm.pptxsvm.pptx
svm.pptx
 
Sentiment Analysis
Sentiment AnalysisSentiment Analysis
Sentiment Analysis
 
Deep Learning - Overview of my work II
Deep Learning - Overview of my work IIDeep Learning - Overview of my work II
Deep Learning - Overview of my work II
 
Machine learning vs deep learning
Machine learning vs deep learningMachine learning vs deep learning
Machine learning vs deep learning
 
Introduction to Linear Discriminant Analysis
Introduction to Linear Discriminant AnalysisIntroduction to Linear Discriminant Analysis
Introduction to Linear Discriminant Analysis
 
Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
 
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
 
Lstm
LstmLstm
Lstm
 
Recurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRURecurrent Neural Networks, LSTM and GRU
Recurrent Neural Networks, LSTM and GRU
 
Machine Learning - Dataset Preparation
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
 
Lasso and ridge regression
Lasso and ridge regressionLasso and ridge regression
Lasso and ridge regression
 
What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...
What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...
What Is A Neural Network? | How Deep Neural Networks Work | Neural Network Tu...
 
forestFloorパッケージを使ったrandomForestの感度分析
forestFloorパッケージを使ったrandomForestの感度分析forestFloorパッケージを使ったrandomForestの感度分析
forestFloorパッケージを使ったrandomForestの感度分析
 
Machine Learning presentation.
Machine Learning presentation.Machine Learning presentation.
Machine Learning presentation.
 
Introduction to Autoencoders
Introduction to AutoencodersIntroduction to Autoencoders
Introduction to Autoencoders
 
Dimensionality Reduction
Dimensionality ReductionDimensionality Reduction
Dimensionality Reduction
 

Ähnlich wie 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, 2016Chris Fregly
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasOswald Campesato
 
TensorFlow for IITians
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITiansAshish Bansal
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016Andrii Babii
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlowOswald Campesato
 
Introduction to TensorFlow
Introduction to TensorFlowIntroduction to TensorFlow
Introduction to TensorFlowBabu Priyavrat
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and SparkOswald Campesato
 
Introduction To Using TensorFlow & Deep Learning
Introduction To Using TensorFlow & Deep LearningIntroduction To Using TensorFlow & Deep Learning
Introduction To Using TensorFlow & Deep Learningali 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 TENSORFLOWMark Chang
 
A Tour of Tensorflow's APIs
A Tour of Tensorflow's APIsA Tour of Tensorflow's APIs
A Tour of Tensorflow's APIsDean 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 | EdurekaEdureka!
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your BrowserOswald Campesato
 

Ähnlich wie 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
 

Mehr von Andrew Ferlitsch

Pareto Principle Applied to QA
Pareto Principle Applied to QAPareto Principle Applied to QA
Pareto Principle Applied to QAAndrew Ferlitsch
 
Whiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonAndrew Ferlitsch
 
Object Oriented Programming Principles
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming PrinciplesAndrew 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 NotepadAndrew Ferlitsch
 
Natural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) GenerationNatural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) GenerationAndrew 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 NetworksAndrew 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 NetworksAndrew Ferlitsch
 
Machine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural NetworksMachine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural NetworksAndrew 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 LibrariesAndrew Ferlitsch
 
Machine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion MatrixMachine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion MatrixAndrew Ferlitsch
 
Machine Learning - Ensemble Methods
Machine Learning - Ensemble MethodsMachine Learning - Ensemble Methods
Machine Learning - Ensemble MethodsAndrew Ferlitsch
 
ML - Multiple Linear Regression
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear RegressionAndrew Ferlitsch
 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear RegressionAndrew Ferlitsch
 
Machine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable ConversionMachine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable ConversionAndrew Ferlitsch
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningAndrew Ferlitsch
 
AI - Introduction to Dynamic Programming
AI - Introduction to Dynamic ProgrammingAI - Introduction to Dynamic Programming
AI - Introduction to Dynamic ProgrammingAndrew Ferlitsch
 
Statistics - SoftMax Equation
Statistics - SoftMax EquationStatistics - SoftMax Equation
Statistics - SoftMax EquationAndrew Ferlitsch
 

Mehr von 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
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
AI - Introduction to Dynamic Programming
AI - Introduction to Dynamic ProgrammingAI - Introduction to Dynamic Programming
AI - Introduction to Dynamic Programming
 
Statistics - SoftMax Equation
Statistics - SoftMax EquationStatistics - SoftMax Equation
Statistics - SoftMax Equation
 

Kürzlich hochgeladen

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

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