Machine Learning - Introduction to Tensorflow

A
Andrew FerlitschSecurity Engineer/Consultant at AllMed Healthcare Management
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
1 de 19

Recomendados

Transferring Changes Between Perforce Servers por
Transferring Changes Between Perforce ServersTransferring Changes Between Perforce Servers
Transferring Changes Between Perforce ServersPerforce
5.5K visualizações28 slides
Mid point line Algorithm - Computer Graphics por
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
27.2K visualizações12 slides
Design and Simulation Triple-DES por
Design and Simulation Triple-DESDesign and Simulation Triple-DES
Design and Simulation Triple-DESchatsiri
3K visualizações34 slides
Visual pattern recognition por
Visual pattern recognitionVisual pattern recognition
Visual pattern recognitionRushin Shah
2.4K visualizações52 slides
Medical image compression por
Medical image compressionMedical image compression
Medical image compressionParamjeet Singh Jamwal
2.3K visualizações23 slides
Huffman Coding por
Huffman CodingHuffman Coding
Huffman Codinganithabalaprabhu
28.3K visualizações24 slides

Mais conteúdo relacionado

Mais procurados

Unit 1 - ML - Introduction to Machine Learning.pptx por
Unit 1 - ML - Introduction to Machine Learning.pptxUnit 1 - ML - Introduction to Machine Learning.pptx
Unit 1 - ML - Introduction to Machine Learning.pptxjawad184956
445 visualizações74 slides
SHA- Secure hashing algorithm por
SHA- Secure hashing algorithmSHA- Secure hashing algorithm
SHA- Secure hashing algorithmRuchi Maurya
11.1K visualizações16 slides
Modern Block Cipher- Modern Symmetric-Key Cipher por
Modern Block Cipher- Modern Symmetric-Key CipherModern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key CipherMahbubur Rahman
12.5K visualizações40 slides
linear classification por
linear classificationlinear classification
linear classificationnep_test_account
2.2K visualizações39 slides
Rpl dodag por
Rpl dodagRpl dodag
Rpl dodagTonachi Shika
12.4K visualizações37 slides
Mitchell's Face Recognition por
Mitchell's Face RecognitionMitchell's Face Recognition
Mitchell's Face Recognitionbutest
440 visualizações19 slides

Mais procurados(20)

Unit 1 - ML - Introduction to Machine Learning.pptx por jawad184956
Unit 1 - ML - Introduction to Machine Learning.pptxUnit 1 - ML - Introduction to Machine Learning.pptx
Unit 1 - ML - Introduction to Machine Learning.pptx
jawad184956445 visualizações
SHA- Secure hashing algorithm por Ruchi Maurya
SHA- Secure hashing algorithmSHA- Secure hashing algorithm
SHA- Secure hashing algorithm
Ruchi Maurya11.1K visualizações
Modern Block Cipher- Modern Symmetric-Key Cipher por Mahbubur Rahman
Modern Block Cipher- Modern Symmetric-Key CipherModern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key Cipher
Mahbubur Rahman12.5K visualizações
linear classification por nep_test_account
linear classificationlinear classification
linear classification
nep_test_account2.2K visualizações
Rpl dodag por Tonachi Shika
Rpl dodagRpl dodag
Rpl dodag
Tonachi Shika12.4K visualizações
Mitchell's Face Recognition por butest
Mitchell's Face RecognitionMitchell's Face Recognition
Mitchell's Face Recognition
butest440 visualizações
Speech Processing with deep learning por Mohamed Essam
Speech Processing  with deep learningSpeech Processing  with deep learning
Speech Processing with deep learning
Mohamed Essam102 visualizações
Character Recognition using Machine Learning por RitwikSaurabh1
Character Recognition using Machine LearningCharacter Recognition using Machine Learning
Character Recognition using Machine Learning
RitwikSaurabh12.1K visualizações
EULER AND FERMAT THEOREM por ankita pandey
EULER AND FERMAT THEOREMEULER AND FERMAT THEOREM
EULER AND FERMAT THEOREM
ankita pandey30.6K visualizações
Handwritten Character Recognition: A Comprehensive Review on Geometrical Anal... por iosrjce
Handwritten Character Recognition: A Comprehensive Review on Geometrical Anal...Handwritten Character Recognition: A Comprehensive Review on Geometrical Anal...
Handwritten Character Recognition: A Comprehensive Review on Geometrical Anal...
iosrjce1.3K visualizações
ppt on region segmentation by AJAY KUMAR SINGH (NITK) por Ajay Kumar Singh
ppt on region segmentation by AJAY KUMAR SINGH (NITK)ppt on region segmentation by AJAY KUMAR SINGH (NITK)
ppt on region segmentation by AJAY KUMAR SINGH (NITK)
Ajay Kumar Singh803 visualizações
Advanced encryption standard (aes) por farazvirk554
Advanced encryption standard (aes)Advanced encryption standard (aes)
Advanced encryption standard (aes)
farazvirk554554 visualizações
Dip 5 mathematical preliminaries por Manas Mantri
Dip 5 mathematical preliminariesDip 5 mathematical preliminaries
Dip 5 mathematical preliminaries
Manas Mantri1.5K visualizações
Information and data security block cipher and the data encryption standard (... por Mazin Alwaaly
Information and data security block cipher and the data encryption standard (...Information and data security block cipher and the data encryption standard (...
Information and data security block cipher and the data encryption standard (...
Mazin Alwaaly2.1K visualizações
Hit and-miss transform por Krish Everglades
Hit and-miss transformHit and-miss transform
Hit and-miss transform
Krish Everglades5.8K visualizações
Linear models for classification por Sung Yub Kim
Linear models for classificationLinear models for classification
Linear models for classification
Sung Yub Kim2.5K visualizações
Computer graphics question for exam solved por Kuntal Bhowmick
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
Kuntal Bhowmick2.6K visualizações

Similar a Machine Learning - Introduction to Tensorflow

Advanced Spark and TensorFlow Meetup May 26, 2016 por
Advanced Spark and TensorFlow Meetup May 26, 2016Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016Chris Fregly
4.3K visualizações75 slides
TensorFlow Tutorial.pdf por
TensorFlow Tutorial.pdfTensorFlow Tutorial.pdf
TensorFlow Tutorial.pdfAntonio Espinosa
48 visualizações44 slides
Introduction to TensorFlow 2 por
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
843 visualizações98 slides
Introduction to TensorFlow 2 and Keras por
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasOswald Campesato
465 visualizações100 slides
TensorFlow for IITians por
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITiansAshish Bansal
181 visualizações62 slides
TensorFlow example for AI Ukraine2016 por
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016Andrii Babii
1.2K visualizações33 slides

Similar a Machine Learning - Introduction to Tensorflow(20)

Advanced Spark and TensorFlow Meetup May 26, 2016 por Chris Fregly
Advanced Spark and TensorFlow Meetup May 26, 2016Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016
Chris Fregly4.3K visualizações
TensorFlow Tutorial.pdf por Antonio Espinosa
TensorFlow Tutorial.pdfTensorFlow Tutorial.pdf
TensorFlow Tutorial.pdf
Antonio Espinosa48 visualizações
Introduction to TensorFlow 2 por Oswald Campesato
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
Oswald Campesato843 visualizações
Introduction to TensorFlow 2 and Keras por Oswald Campesato
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
Oswald Campesato465 visualizações
TensorFlow for IITians por Ashish Bansal
TensorFlow for IITiansTensorFlow for IITians
TensorFlow for IITians
Ashish Bansal181 visualizações
TensorFlow example for AI Ukraine2016 por Andrii Babii
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016
Andrii Babii1.2K visualizações
Deep Learning and TensorFlow por Oswald Campesato
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
Oswald Campesato114 visualizações
Introduction to TensorFlow por Babu Priyavrat
Introduction to TensorFlowIntroduction to TensorFlow
Introduction to TensorFlow
Babu Priyavrat1.3K visualizações
Deep Learning, Scala, and Spark por Oswald Campesato
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
Oswald Campesato312 visualizações
Introduction To Using TensorFlow & Deep Learning por ali alemi
Introduction To Using TensorFlow & Deep LearningIntroduction To Using TensorFlow & Deep Learning
Introduction To Using TensorFlow & Deep Learning
ali alemi261 visualizações
Tensorflow - Intro (2017) por Alessio Tonioni
Tensorflow - Intro (2017)Tensorflow - Intro (2017)
Tensorflow - Intro (2017)
Alessio Tonioni2.2K visualizações
Working with tf.data (TF 2) por Oswald Campesato
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
Oswald Campesato329 visualizações
NTU ML TENSORFLOW por Mark Chang
NTU ML TENSORFLOWNTU ML TENSORFLOW
NTU ML TENSORFLOW
Mark Chang4.9K visualizações
Meetup tensorframes por Paolo Platter
Meetup tensorframesMeetup tensorframes
Meetup tensorframes
Paolo Platter517 visualizações
A Tour of Tensorflow's APIs por Dean Wyatte
A Tour of Tensorflow's APIsA Tour of Tensorflow's APIs
A Tour of Tensorflow's APIs
Dean Wyatte218 visualizações
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習 por NTC.im(Notch Training Center)
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC_Tensor flow 深度學習快速上手班_Part1 -機器學習
NTC.im(Notch Training Center)779 visualizações
TensorFlow 深度學習快速上手班--機器學習 por Mark Chang
TensorFlow 深度學習快速上手班--機器學習TensorFlow 深度學習快速上手班--機器學習
TensorFlow 深度學習快速上手班--機器學習
Mark Chang4.4K visualizações
Theano vs TensorFlow | Edureka por Edureka!
Theano vs TensorFlow | EdurekaTheano vs TensorFlow | Edureka
Theano vs TensorFlow | Edureka
Edureka!108 visualizações
TensorFlow in Your Browser por Oswald Campesato
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
Oswald Campesato225 visualizações

Mais de Andrew Ferlitsch

AI - Intelligent Agents por
AI - Intelligent AgentsAI - Intelligent Agents
AI - Intelligent AgentsAndrew Ferlitsch
4.6K visualizações13 slides
Pareto Principle Applied to QA por
Pareto Principle Applied to QAPareto Principle Applied to QA
Pareto Principle Applied to QAAndrew Ferlitsch
1.6K visualizações29 slides
Whiteboarding Coding Challenges in Python por
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonAndrew Ferlitsch
1.6K visualizações89 slides
Object Oriented Programming Principles por
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming PrinciplesAndrew Ferlitsch
1.6K visualizações8 slides
Python - OOP Programming por
Python - OOP ProgrammingPython - OOP Programming
Python - OOP ProgrammingAndrew Ferlitsch
1K visualizações9 slides
Python - Installing and Using Python and Jupyter Notepad por
Python - Installing and Using Python and Jupyter NotepadPython - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter NotepadAndrew Ferlitsch
352 visualizações6 slides

Mais de Andrew Ferlitsch(20)

AI - Intelligent Agents por Andrew Ferlitsch
AI - Intelligent AgentsAI - Intelligent Agents
AI - Intelligent Agents
Andrew Ferlitsch4.6K visualizações
Pareto Principle Applied to QA por Andrew Ferlitsch
Pareto Principle Applied to QAPareto Principle Applied to QA
Pareto Principle Applied to QA
Andrew Ferlitsch1.6K visualizações
Whiteboarding Coding Challenges in Python por Andrew Ferlitsch
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in Python
Andrew Ferlitsch1.6K visualizações
Object Oriented Programming Principles por Andrew Ferlitsch
Object Oriented Programming PrinciplesObject Oriented Programming Principles
Object Oriented Programming Principles
Andrew Ferlitsch1.6K visualizações
Python - OOP Programming por Andrew Ferlitsch
Python - OOP ProgrammingPython - OOP Programming
Python - OOP Programming
Andrew Ferlitsch1K visualizações
Python - Installing and Using Python and Jupyter Notepad por Andrew Ferlitsch
Python - Installing and Using Python and Jupyter NotepadPython - Installing and Using Python and Jupyter Notepad
Python - Installing and Using Python and Jupyter Notepad
Andrew Ferlitsch352 visualizações
Natural Language Processing - Groupings (Associations) Generation por Andrew Ferlitsch
Natural Language Processing - Groupings (Associations) GenerationNatural Language Processing - Groupings (Associations) Generation
Natural Language Processing - Groupings (Associations) Generation
Andrew Ferlitsch235 visualizações
Natural Language Provessing - Handling Narrarive Fields in Datasets for Class... por 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...
Andrew Ferlitsch223 visualizações
Machine Learning - Introduction to Recurrent Neural Networks por Andrew Ferlitsch
Machine Learning - Introduction to Recurrent Neural NetworksMachine Learning - Introduction to Recurrent Neural Networks
Machine Learning - Introduction to Recurrent Neural Networks
Andrew Ferlitsch371 visualizações
Machine Learning - Introduction to Convolutional Neural Networks por Andrew Ferlitsch
Machine Learning - Introduction to Convolutional Neural NetworksMachine Learning - Introduction to Convolutional Neural Networks
Machine Learning - Introduction to Convolutional Neural Networks
Andrew Ferlitsch1.4K visualizações
Machine Learning - Introduction to Neural Networks por Andrew Ferlitsch
Machine Learning - Introduction to Neural NetworksMachine Learning - Introduction to Neural Networks
Machine Learning - Introduction to Neural Networks
Andrew Ferlitsch270 visualizações
Python - Numpy/Pandas/Matplot Machine Learning Libraries por Andrew Ferlitsch
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Andrew Ferlitsch3.5K visualizações
Machine Learning - Accuracy and Confusion Matrix por Andrew Ferlitsch
Machine Learning - Accuracy and Confusion MatrixMachine Learning - Accuracy and Confusion Matrix
Machine Learning - Accuracy and Confusion Matrix
Andrew Ferlitsch3.3K visualizações
Machine Learning - Ensemble Methods por Andrew Ferlitsch
Machine Learning - Ensemble MethodsMachine Learning - Ensemble Methods
Machine Learning - Ensemble Methods
Andrew Ferlitsch2.2K visualizações
ML - Multiple Linear Regression por Andrew Ferlitsch
ML - Multiple Linear RegressionML - Multiple Linear Regression
ML - Multiple Linear Regression
Andrew Ferlitsch2.5K visualizações
ML - Simple Linear Regression por Andrew Ferlitsch
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
Andrew Ferlitsch3.1K visualizações
Machine Learning - Dummy Variable Conversion por Andrew Ferlitsch
Machine Learning - Dummy Variable ConversionMachine Learning - Dummy Variable Conversion
Machine Learning - Dummy Variable Conversion
Andrew Ferlitsch768 visualizações
Machine Learning - Splitting Datasets por Andrew Ferlitsch
Machine Learning - Splitting DatasetsMachine Learning - Splitting Datasets
Machine Learning - Splitting Datasets
Andrew Ferlitsch4.6K visualizações
Machine Learning - Dataset Preparation por Andrew Ferlitsch
Machine Learning - Dataset PreparationMachine Learning - Dataset Preparation
Machine Learning - Dataset Preparation
Andrew Ferlitsch2K visualizações
Introduction to Machine Learning por Andrew Ferlitsch
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
Andrew Ferlitsch284 visualizações

Último

Business Analyst Series 2023 - Week 3 Session 5 por
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5DianaGray10
300 visualizações20 slides
Design Driven Network Assurance por
Design Driven Network AssuranceDesign Driven Network Assurance
Design Driven Network AssuranceNetwork Automation Forum
15 visualizações42 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... por
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
40 visualizações69 slides
NET Conf 2023 Recap por
NET Conf 2023 RecapNET Conf 2023 Recap
NET Conf 2023 RecapLee Richardson
10 visualizações71 slides
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... por
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc
11 visualizações29 slides
PRODUCT PRESENTATION.pptx por
PRODUCT PRESENTATION.pptxPRODUCT PRESENTATION.pptx
PRODUCT PRESENTATION.pptxangelicacueva6
15 visualizações1 slide

Último(20)

Business Analyst Series 2023 - Week 3 Session 5 por DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10300 visualizações
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... por Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker40 visualizações
NET Conf 2023 Recap por Lee Richardson
NET Conf 2023 RecapNET Conf 2023 Recap
NET Conf 2023 Recap
Lee Richardson10 visualizações
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... por TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc11 visualizações
PRODUCT PRESENTATION.pptx por angelicacueva6
PRODUCT PRESENTATION.pptxPRODUCT PRESENTATION.pptx
PRODUCT PRESENTATION.pptx
angelicacueva615 visualizações
Igniting Next Level Productivity with AI-Infused Data Integration Workflows por Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software280 visualizações
Info Session November 2023.pdf por AleksandraKoprivica4
Info Session November 2023.pdfInfo Session November 2023.pdf
Info Session November 2023.pdf
AleksandraKoprivica413 visualizações
Melek BEN MAHMOUD.pdf por MelekBenMahmoud
Melek BEN MAHMOUD.pdfMelek BEN MAHMOUD.pdf
Melek BEN MAHMOUD.pdf
MelekBenMahmoud14 visualizações
Powerful Google developer tools for immediate impact! (2023-24) por wesley chun
Powerful Google developer tools for immediate impact! (2023-24)Powerful Google developer tools for immediate impact! (2023-24)
Powerful Google developer tools for immediate impact! (2023-24)
wesley chun10 visualizações
Unit 1_Lecture 2_Physical Design of IoT.pdf por StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 visualizações
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf por Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
Dr. Jimmy Schwarzkopf20 visualizações
Future of AR - Facebook Presentation por ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56115 visualizações
Uni Systems for Power Platform.pptx por Uni Systems S.M.S.A.
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptx
Uni Systems S.M.S.A.56 visualizações
STPI OctaNE CoE Brochure.pdf por madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 visualizações
PharoJS - Zürich Smalltalk Group Meetup November 2023 por Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi132 visualizações
Mini-Track: AI and ML in Network Operations Applications por Network Automation Forum
Mini-Track: AI and ML in Network Operations ApplicationsMini-Track: AI and ML in Network Operations Applications
Mini-Track: AI and ML in Network Operations Applications
Network Automation Forum10 visualizações

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