SlideShare a Scribd company logo
1 of 66
#WTMIndia
#WTMIndia
Introduction to
Machine Learning
and Tensorflow
Lakshya Sivaramakrishnan
Program Coordinator, Women Techmakers
@lakshyas90
#WTMIndia
Human Learning
Features Labels
Colour Texture Taste Fruit
Red Smooth Sweet Apple
Orange Bumpy Sweet-Sour Orange
#WTMIndia
Machine Learning
The ability to learn without being explicitly
programmed.
or
Algorithm or model that learns patterns
in data and then predicts similar
patterns in new data.
or
Learning from experiences and examples.
Algorithm InsightData
#WTMIndia
When is the last
time you
experienced ML ?
#WTMIndia
It’s with us 24*7
(day in and day out)
#WTMIndia
Machine Learning
Artificial Intelligence
Neural Network
AI, ML, NN - Are all the same?
#WTMIndia
Why is ML important?
To solve interesting use cases
● Making speech recognition and machine translation
possible.
● The new search feature in Google Photos, which
received broad acclaim.
● Recognizing pedestrians and other vehicles in
self-driving cars
#WTMIndia
How Can You Get Started with ML?
Three ways, with varying complexity:
(1) Use a Cloud-based or Mobile API (Vision, Natural Language,
etc.)
(2) Use an existing model architecture, and retrain it or fine tune
on your dataset
(3) Develop your own machine learning models for new
problems
More
flexible,
but more
effort
required
#WTMIndia
Review:What/Why/How of ML
WHAT
Algorithms that can generate insights by learning from data.
WHY
Because algorithms can learn faster, cheaper, and better than
humans.
HOW
By finding patterns in data.
#WTMIndia
The Process
Algorithm
Model
New Data
Training
Predictions
Examples
#WTMIndia
Workflow
Apple
Orange
#WTMIndia
The processof ‘Learning’
SUPERVISED UNSUPERVISED REINFORCEMENT
Image Credits : https://goo.gl/xU5KCv, https://goo.gl/aDjjFR, https://goo.gl/3NGzuW
#WTMIndia
SupervisedLearning
SUPERVISED
● Teach the machine using data that’s well labelled
● Has prior knowledge of output
● Data is labelled with class or value
● Task driven
● Goal : predict class or value label
● Neural network, support vector machines , decision
trees etc
Image Credits : https://goo.gl/xU5KCv
#WTMIndia
UnsupervisedLearning
UNSUPERVISED
● Data set with no label
● Learning algo is not told what is being learnt
● No knowledge of output class of value
● Data driven
● Goal : determine patterns or grouping
● K-means, genetic algorithms, clustering
Image Credits : https://goo.gl/aDjjFR
#WTMIndia
Reinforcement Learning
REINFORCEMENT
● Similar to unsupervised learning
● Uses unlabelled data
● Outcome is evaluated and reward is fed back to
change the algo
● Algo learns to act in a given environment to achieve
a goal
● Goal driven
Image Credits : https://goo.gl/3NGzuW
#WTMIndia
Machine Learning use cases at Google
Search
Search ranking
Speech recognition
Android
Keyboard & speech input
Gmail
Smart reply
Spam classification
Drive
Intelligence in Apps
Chrome
Search by image
Assistant
Smart connections
across products
Maps
Parsing local search
Translate
Text, graphic and speech
translation
Cardboard
Smart stitching
Photos
Photos search
#WTMIndia
Smart reply
in Inbox by Gmail
10%
of all responses
sent on mobile
#WTMIndia
#WTMIndia
#WTMIndia
Neural Networks
● Interconnected web of nodes = neurons
● Receives a set of inputs, perform
calculations & use output to solve a
problem
● eg ) classification
● Multiple layer
● Use backpropagation to adjust the weights
Image Credits : https://goo.gl/H7mNnT
#WTMIndia
A multidimensional array.
A graph of operations.
#WTMIndia
● Fast, flexible, and scalable
open-source machine learning
library
● For research and production
● Runs on CPU, GPU, Android, iOS,
Raspberry Pi, Datacenters, Mobile
● Apache 2.0 license
https://research.googleblog.com/2016/11/celebrating-tensorflows-first-year.html
#WTMIndia
Sharing our tools with researchers and developers
around the world
repository
for “machine
learning”
category on
GitHub
Released in
Nov. 2015
#WTMIndia
What can we do with tensor flow?
#WTMIndia
Shared Research in TensorFlow
Inception https://research.googleblog.com/2016/08/improving-inception-and-image.html
Show and Tell https://research.googleblog.com/2016/09/show-and-tell-image-captioning-open.html
Parsey McParseface https://research.googleblog.com/2016/05/announcing-syntaxnet-worlds-most.html
Translation https://research.googleblog.com/2016/09/a-neural-network-for-machine.html
Summarization https://research.googleblog.com/2016/08/text-summarization-with-tensorflow.html
Pathology https://research.googleblog.com/2017/03/assisting-pathologists-in-detecting.html
#WTMIndia
BuildingModels
CONSTRUCTION PHASE
● Assembles the graph
● Define the computation graph
○ Input, Operations, Output
EXECUTION PHASE
● Executes operations in the graph
● Run Session
○ Execute graph and fetch output
Tensorflow programs are generally structured into two phases.
#WTMIndia
Build a graph; then run it.
...
c = tf.add(a, b)
...
session = tf.Session()
value_of_c = session.run(c, {a=1, b=2})
add
a b
c
TensorFlow separates computation graph construction from execution.
#WTMIndia
Let’s writesome code.
#WTMIndia
Code Demos
Hello World Matrix
Multiplication
Character
recognition
Fun experiments
#WTMIndia
Let’s dive deep into code - Hello World!
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print sess.run(hello)
Tell the compiler that you want to use all
functionalities that come with the
tensorflow package.
Create a constant op. This op is added as
a node to the default graph.
Start a session.
Run the operation and get the result.
Source : https://github.com/lakshya90/wwc-workshop/blob/master/hello_world.py
#WTMIndia
Let’s try Matrix Multiplication in TF
import tensorflow as tf
matrix1 = tf.constant([[3, 3]])
matrix2 = tf.constant([[2],[2]])
product = tf.matmul(matrix1, matrix2)
Tell the compiler that you want to use all functionalities
that come with the tensorflow package.
Create a constant op that produces a 1x2 matrix. The op is
added as a node to the default graph.The value returned by
the constructor represents the output of the Constant op.
Create another constant that produces a 2x1 matrix.
Create a matmul op that takes 'matrix1' and 'matrix2' as
inputs. The returned value, 'product', represents the result
of the matrix multiplication.
CONSTRUCTION PHASE
Source : https://github.com/lakshya90/wwc-workshop/blob/master/mat_mul.py
#WTMIndia
Trying Matrix Multiplication in TF
sess = tf.Session()
result = sess.run(product)
print(result)
sess.close()
Launch the default graph.
To run the matmul op we call the session 'run()' method,
passing 'product' which represents the output of the matmul op.
This indicates to the call that we want to get the output of the
matmul op back. All inputs needed by the op are run
automatically by the session. They typically are run in parallel.
The call 'run(product)' thus causes the execution of three ops in
the graph: the two constants and matmul.
The output of the op is returned in 'result' as a numpy `ndarray`
object. ==> [[ 12]]
Close the Session when we are done.
EXECUTION PHASE
Source : https://github.com/lakshya90/wwc-workshop/blob/master/mat_mul.py
#WTMIndia
What do we know so far ?
● Represents computations as graphs.
● Executes graphs in the context of Sessions.
● Represents data as tensors.
● Maintains state with Variables.
● Uses feeds and fetches to get data into and out of arbitrary operations.
Image from https://github.com/mnielsen/neural-networks-and-deep-learning
?
Hello Computer Vision World
#WTMIndia
What we see What the computer “sees”
#WTMIndia
Difficult without Machine Learning
def classify (pixels):
# handwritten rules ...
# ...
# ...
return 8
An image of a
handwritten digit
#WTMIndia
Machine Learning approach
Data
#WTMIndia
import tensorflow as tf
mnist = tf.contrib.learn.datasets.load_dataset('mnist')
Images
Labels 5 0 4 1 9 2
MNIST
#WTMIndia
Training data Testing data
training_data = mnist.train.images
training_labels = mnist.train.labels
testing_data = mnist.test.images
testing_labels = mnist.test.labels
#WTMIndia
Classifier
Training data Testing data
classifier = tf.learn.LinearClassifier(n_classes=10)
#WTMIndia
classifier = tf.learn.LinearClassifier(n_classes=10)
...
...
0 1 2 9
28x28
pixels
784 pixels
Connect each input
to each output
#WTMIndia
...
...
0 1 2 9
Weights
w1,0 w1,1 w1,2 w1,9
28x28
pixels
784 pixels
classifier = tf.learn.LinearClassifier(n_classes=10)
#WTMIndia
Fully connected
...
...
0 1 2 9
28x28
pixels
784 pixels
classifier = tf.learn.LinearClassifier(n_classes=10)
#WTMIndia
...
...
0 1 2 9
28x28
pixels
784 pixels
classifier = tf.learn.LinearClassifier(n_classes=10)
WeightInput
#WTMIndia
classifier.fit(mnist.train.images, mnist.train.labels)
...
...
0 1 2 9
28x28
pixels
784 pixels
#WTMIndia
Backpropagation
Error
Start
Gradient descent
#WTMIndia
Training data Testing data
Output: a prediction “1”
Input:
an image
#WTMIndia
Training data Testing data
Output: “8”
Input:
an image
#WTMIndia
score = metrics.accuracy_score(mnist.test.labels,
classifier.predict(mnist.test.images))
...
...
0 1 2 9
28x28
pixels
784 pixels actual label
predicted label
#WTMIndia
score = metrics.accuracy_score(mnist.test.labels,
classifier.predict(mnist.test.images))
...
...
0 1 2 9
92% accuracy
Is this good?
28x28
pixels
784 pixels
#WTMIndia
#WTMIndia
Using TensorFlow on MNIST
import numpy as np
import tensorflow as tf
import tf.contrib.learn as learn
mnist = learn.datasets.load_dataset('mnist')
data = mnist.train.images
labels = np.asarray(mnist.train.labels, dtype=np.int32)
test_data = mnist.test.images
test_labels = np.asarray(mnist.test.labels, dtype=np.int32)
feature_columns = learn.infer_real_valued_columns_from_input(data)
classifier = learn.LinearClassifier(feature_columns=feature_columns, n_classes=10)
classifier.fit(data, labels, batch_size=100, steps=1000)
classifier.evaluate(test_data, test_labels)
print classifier.evaluate(test_data, test_labels)["accuracy"]
Import required libraries
Import the dataset
Fit a linear classifier
Evaluate accuracy
Source : https://github.com/lakshya90/wwc-workshop/blob/master/mnist.py
...
...
0 1 2 9
{Hidden
layers
#WTMIndia
import tensorflow as tf
mnist = tf.contrib.learn.datasets.load_dataset('mnist')
classifier = tf.learn.DNNClassifier(n_classes=10, 
hidden_units[1024,512,256)
classifier.fit(mnist.train.images, mnist.train.labels)
score = metrics.accuracy_score(mnist.test.labels, 
classifier.predict(mnist.test.images))
print('Accuracy: {0:f}'.format(score))
#WTMIndia
#WTMIndia
Using TensorFlow on MNIST
import numpy as np
import tensorflow as tf
import tf.contrib.learn as learn
mnist = learn.datasets.load_dataset('mnist')
data = mnist.train.images
labels = np.asarray(mnist.train.labels, dtype=np.int32)
test_data = mnist.test.images
test_labels = np.asarray(mnist.test.labels, dtype=np.int32)
feature_columns = learn.infer_real_valued_columns_from_input(data)
classifier = learn.DNNClassifier(feature_columns=feature_columns, n_classes=10,
hidden_units = [1024,512,256])
classifier.fit(data, labels, batch_size=100, steps=1000)
classifier.evaluate(test_data, test_labels)
print classifier.evaluate(test_data, test_labels)["accuracy"]
Import required libraries
Import the dataset
Fit a linear classifier
Evaluate accuracy
Source : https://github.com/lakshya90/wwc-workshop/blob/master/mnist_DNN.py
#WTMIndia
Fun experiments
+ = ?
#WTMIndia
Fun experiments
+ =
#WTMIndia
What Does A.I. Have To Do With This Selfie?
#WTMIndia
● Step 1 : Get the content and style image.
● Step 2 : Import the neural_style.py, stylize.py and vgg.py file. Ensure the mat file is
present in your top level directory.
○ https://github.com/lakshya90/wwc-workshop, https://goo.gl/2hck1z
● Step 3 : Get your style transferred image.
○ python neural_style.py --content <content-file> --styles <style-file> --output <output-file>
Try them out - goo.gl/fyDxhC
#WTMIndia
Source : https://github.com/lakshya90/wwc-workshop/tree/master/style_transfer
#WTMIndia
Challenge
Push your code to GITHUB
https://guides.github.com/activities/hello-world/
http://rogerdudler.github.io/git-guide/
RESOURCES :
https://github.com/lakshya90/wwc-workshop
Lots of tutorials at tensorflow.org
#WTMIndia
Codelab - goo.gl/xGsB9d Video - goo.gl/B2zYWN
TensorFlow for Poets
#WTMIndia
tensorflow.org
github.com/tensorflow
Want to learn more?
Udacity class on Deep Learning, goo.gl/iHssII
Guides, codelabs, videos
MNIST for Beginners, goo.gl/tx8R2b
TF Learn Quickstart, goo.gl/uiefRn
TensorFlow for Poets, goo.gl/bVjFIL
ML Recipes, goo.gl/KewA03
TensorFlow and Deep Learning without a PhD, goo.gl/pHeXe7
Next steps
#WTMIndia
#WTMIndia
Thank You!
Lakshya Sivaramakrishnan
@lakshyas90

More Related Content

What's hot

Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...Simplilearn
 
Machine Learning
Machine LearningMachine Learning
Machine LearningShrey Malik
 
Feature Engineering in Machine Learning
Feature Engineering in Machine LearningFeature Engineering in Machine Learning
Feature Engineering in Machine LearningKnoldus Inc.
 
Introduction to ML (Machine Learning)
Introduction to ML (Machine Learning)Introduction to ML (Machine Learning)
Introduction to ML (Machine Learning)SwatiTripathi44
 
Final thesis presentation
Final thesis presentationFinal thesis presentation
Final thesis presentationPawan Singh
 
Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Databricks
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningKmPooja4
 
Machine Learning
Machine LearningMachine Learning
Machine LearningVivek Garg
 
Machine Learning
Machine LearningMachine Learning
Machine LearningRahul Kumar
 
Bayesian networks in AI
Bayesian networks in AIBayesian networks in AI
Bayesian networks in AIByoung-Hee Kim
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Simplilearn
 
Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree LearningMilind Gokhale
 
Introduction to Interpretable Machine Learning
Introduction to Interpretable Machine LearningIntroduction to Interpretable Machine Learning
Introduction to Interpretable Machine LearningNguyen Giang
 
Presentation on supervised learning
Presentation on supervised learningPresentation on supervised learning
Presentation on supervised learningTonmoy Bhagawati
 
Machine learning with ADA Boost
Machine learning with ADA BoostMachine learning with ADA Boost
Machine learning with ADA BoostAman Patel
 

What's hot (20)

Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning
 
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
 
Machine learning
Machine learningMachine learning
Machine learning
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Feature Engineering in Machine Learning
Feature Engineering in Machine LearningFeature Engineering in Machine Learning
Feature Engineering in Machine Learning
 
supervised learning
supervised learningsupervised learning
supervised learning
 
Machine learning
Machine learningMachine learning
Machine learning
 
Introduction to ML (Machine Learning)
Introduction to ML (Machine Learning)Introduction to ML (Machine Learning)
Introduction to ML (Machine Learning)
 
Final thesis presentation
Final thesis presentationFinal thesis presentation
Final thesis presentation
 
Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0Introduction to TensorFlow 2.0
Introduction to TensorFlow 2.0
 
Machine learning
Machine learningMachine learning
Machine learning
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Bayesian networks in AI
Bayesian networks in AIBayesian networks in AI
Bayesian networks in AI
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
 
Decision Tree Learning
Decision Tree LearningDecision Tree Learning
Decision Tree Learning
 
Introduction to Interpretable Machine Learning
Introduction to Interpretable Machine LearningIntroduction to Interpretable Machine Learning
Introduction to Interpretable Machine Learning
 
Presentation on supervised learning
Presentation on supervised learningPresentation on supervised learning
Presentation on supervised learning
 
Machine learning with ADA Boost
Machine learning with ADA BoostMachine learning with ADA Boost
Machine learning with ADA Boost
 

Similar to Machine learning workshop

Google Big Data Expo
Google Big Data ExpoGoogle Big Data Expo
Google Big Data ExpoBigDataExpo
 
Creating a custom Machine Learning Model for your applications - Java Dev Day...
Creating a custom Machine Learning Model for your applications - Java Dev Day...Creating a custom Machine Learning Model for your applications - Java Dev Day...
Creating a custom Machine Learning Model for your applications - Java Dev Day...Isabel Palomar
 
Creating a custom ML model for your application - DevFest Lima 2019
Creating a custom ML model for your application - DevFest Lima 2019Creating a custom ML model for your application - DevFest Lima 2019
Creating a custom ML model for your application - DevFest Lima 2019Isabel Palomar
 
Building a custom machine learning model on android
Building a custom machine learning model on androidBuilding a custom machine learning model on android
Building a custom machine learning model on androidIsabel Palomar
 
Creating a Custom ML Model for your Application - Kotlin/Everywhere
Creating a Custom ML Model for your Application - Kotlin/EverywhereCreating a Custom ML Model for your Application - Kotlin/Everywhere
Creating a Custom ML Model for your Application - Kotlin/EverywhereIsabel Palomar
 
Leverage the power of machine learning on windows
Leverage the power of machine learning on windowsLeverage the power of machine learning on windows
Leverage the power of machine learning on windowsMia Chang
 
Inteligencia artificial para android como empezar
Inteligencia artificial para android como empezarInteligencia artificial para android como empezar
Inteligencia artificial para android como empezarIsabel Palomar
 
MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle Databricks
 
2017 arab wic marwa ayad machine learning
2017 arab wic marwa ayad machine learning2017 arab wic marwa ayad machine learning
2017 arab wic marwa ayad machine learningmarwa Ayad Mohamed
 
Leverage the power of machine learning on windows
Leverage the power of machine learning on windowsLeverage the power of machine learning on windows
Leverage the power of machine learning on windowsJosé António Silva
 
Easy path to machine learning
Easy path to machine learningEasy path to machine learning
Easy path to machine learningwesley chun
 
Deep Learning Jump Start
Deep Learning Jump StartDeep Learning Jump Start
Deep Learning Jump StartMichele Toni
 
Kaz Sato, Evangelist, Google at MLconf ATL 2016
Kaz Sato, Evangelist, Google at MLconf ATL 2016Kaz Sato, Evangelist, Google at MLconf ATL 2016
Kaz Sato, Evangelist, Google at MLconf ATL 2016MLconf
 
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)wesley chun
 
Lessons Learned from Building Machine Learning Software at Netflix
Lessons Learned from Building Machine Learning Software at NetflixLessons Learned from Building Machine Learning Software at Netflix
Lessons Learned from Building Machine Learning Software at NetflixJustin Basilico
 
Flyte kubecon 2019 SanDiego
Flyte kubecon 2019 SanDiegoFlyte kubecon 2019 SanDiego
Flyte kubecon 2019 SanDiegoKetanUmare
 
"Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St..."Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St...Stefan Krawczyk
 

Similar to Machine learning workshop (20)

Google Big Data Expo
Google Big Data ExpoGoogle Big Data Expo
Google Big Data Expo
 
Creating a custom Machine Learning Model for your applications - Java Dev Day...
Creating a custom Machine Learning Model for your applications - Java Dev Day...Creating a custom Machine Learning Model for your applications - Java Dev Day...
Creating a custom Machine Learning Model for your applications - Java Dev Day...
 
Creating a custom ML model for your application - DevFest Lima 2019
Creating a custom ML model for your application - DevFest Lima 2019Creating a custom ML model for your application - DevFest Lima 2019
Creating a custom ML model for your application - DevFest Lima 2019
 
Building a custom machine learning model on android
Building a custom machine learning model on androidBuilding a custom machine learning model on android
Building a custom machine learning model on android
 
ML in Android
ML in AndroidML in Android
ML in Android
 
Creating a Custom ML Model for your Application - Kotlin/Everywhere
Creating a Custom ML Model for your Application - Kotlin/EverywhereCreating a Custom ML Model for your Application - Kotlin/Everywhere
Creating a Custom ML Model for your Application - Kotlin/Everywhere
 
Leverage the power of machine learning on windows
Leverage the power of machine learning on windowsLeverage the power of machine learning on windows
Leverage the power of machine learning on windows
 
Inteligencia artificial para android como empezar
Inteligencia artificial para android como empezarInteligencia artificial para android como empezar
Inteligencia artificial para android como empezar
 
MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle MLFlow: Platform for Complete Machine Learning Lifecycle
MLFlow: Platform for Complete Machine Learning Lifecycle
 
2017 arab wic marwa ayad machine learning
2017 arab wic marwa ayad machine learning2017 arab wic marwa ayad machine learning
2017 arab wic marwa ayad machine learning
 
Leverage the power of machine learning on windows
Leverage the power of machine learning on windowsLeverage the power of machine learning on windows
Leverage the power of machine learning on windows
 
Easy path to machine learning
Easy path to machine learningEasy path to machine learning
Easy path to machine learning
 
Persian MNIST in 5 Minutes
Persian MNIST in 5 MinutesPersian MNIST in 5 Minutes
Persian MNIST in 5 Minutes
 
Deep Learning Jump Start
Deep Learning Jump StartDeep Learning Jump Start
Deep Learning Jump Start
 
Introduction to ML.NET
Introduction to ML.NETIntroduction to ML.NET
Introduction to ML.NET
 
Kaz Sato, Evangelist, Google at MLconf ATL 2016
Kaz Sato, Evangelist, Google at MLconf ATL 2016Kaz Sato, Evangelist, Google at MLconf ATL 2016
Kaz Sato, Evangelist, Google at MLconf ATL 2016
 
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)
 
Lessons Learned from Building Machine Learning Software at Netflix
Lessons Learned from Building Machine Learning Software at NetflixLessons Learned from Building Machine Learning Software at Netflix
Lessons Learned from Building Machine Learning Software at Netflix
 
Flyte kubecon 2019 SanDiego
Flyte kubecon 2019 SanDiegoFlyte kubecon 2019 SanDiego
Flyte kubecon 2019 SanDiego
 
"Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St..."Deployment for free": removing the need to write model deployment code at St...
"Deployment for free": removing the need to write model deployment code at St...
 

Recently uploaded

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
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
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governanceWSO2
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
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
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...caitlingebhard1
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseWSO2
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Recently uploaded (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
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...
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
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
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Machine learning workshop

  • 1. #WTMIndia #WTMIndia Introduction to Machine Learning and Tensorflow Lakshya Sivaramakrishnan Program Coordinator, Women Techmakers @lakshyas90
  • 2. #WTMIndia Human Learning Features Labels Colour Texture Taste Fruit Red Smooth Sweet Apple Orange Bumpy Sweet-Sour Orange
  • 3. #WTMIndia Machine Learning The ability to learn without being explicitly programmed. or Algorithm or model that learns patterns in data and then predicts similar patterns in new data. or Learning from experiences and examples. Algorithm InsightData
  • 4. #WTMIndia When is the last time you experienced ML ?
  • 5. #WTMIndia It’s with us 24*7 (day in and day out)
  • 6. #WTMIndia Machine Learning Artificial Intelligence Neural Network AI, ML, NN - Are all the same?
  • 7. #WTMIndia Why is ML important? To solve interesting use cases ● Making speech recognition and machine translation possible. ● The new search feature in Google Photos, which received broad acclaim. ● Recognizing pedestrians and other vehicles in self-driving cars
  • 8. #WTMIndia How Can You Get Started with ML? Three ways, with varying complexity: (1) Use a Cloud-based or Mobile API (Vision, Natural Language, etc.) (2) Use an existing model architecture, and retrain it or fine tune on your dataset (3) Develop your own machine learning models for new problems More flexible, but more effort required
  • 9. #WTMIndia Review:What/Why/How of ML WHAT Algorithms that can generate insights by learning from data. WHY Because algorithms can learn faster, cheaper, and better than humans. HOW By finding patterns in data.
  • 12. #WTMIndia The processof ‘Learning’ SUPERVISED UNSUPERVISED REINFORCEMENT Image Credits : https://goo.gl/xU5KCv, https://goo.gl/aDjjFR, https://goo.gl/3NGzuW
  • 13. #WTMIndia SupervisedLearning SUPERVISED ● Teach the machine using data that’s well labelled ● Has prior knowledge of output ● Data is labelled with class or value ● Task driven ● Goal : predict class or value label ● Neural network, support vector machines , decision trees etc Image Credits : https://goo.gl/xU5KCv
  • 14. #WTMIndia UnsupervisedLearning UNSUPERVISED ● Data set with no label ● Learning algo is not told what is being learnt ● No knowledge of output class of value ● Data driven ● Goal : determine patterns or grouping ● K-means, genetic algorithms, clustering Image Credits : https://goo.gl/aDjjFR
  • 15. #WTMIndia Reinforcement Learning REINFORCEMENT ● Similar to unsupervised learning ● Uses unlabelled data ● Outcome is evaluated and reward is fed back to change the algo ● Algo learns to act in a given environment to achieve a goal ● Goal driven Image Credits : https://goo.gl/3NGzuW
  • 16. #WTMIndia Machine Learning use cases at Google Search Search ranking Speech recognition Android Keyboard & speech input Gmail Smart reply Spam classification Drive Intelligence in Apps Chrome Search by image Assistant Smart connections across products Maps Parsing local search Translate Text, graphic and speech translation Cardboard Smart stitching Photos Photos search
  • 17. #WTMIndia Smart reply in Inbox by Gmail 10% of all responses sent on mobile
  • 20. #WTMIndia Neural Networks ● Interconnected web of nodes = neurons ● Receives a set of inputs, perform calculations & use output to solve a problem ● eg ) classification ● Multiple layer ● Use backpropagation to adjust the weights Image Credits : https://goo.gl/H7mNnT
  • 21.
  • 23. #WTMIndia ● Fast, flexible, and scalable open-source machine learning library ● For research and production ● Runs on CPU, GPU, Android, iOS, Raspberry Pi, Datacenters, Mobile ● Apache 2.0 license https://research.googleblog.com/2016/11/celebrating-tensorflows-first-year.html
  • 24. #WTMIndia Sharing our tools with researchers and developers around the world repository for “machine learning” category on GitHub Released in Nov. 2015
  • 25. #WTMIndia What can we do with tensor flow?
  • 26.
  • 27. #WTMIndia Shared Research in TensorFlow Inception https://research.googleblog.com/2016/08/improving-inception-and-image.html Show and Tell https://research.googleblog.com/2016/09/show-and-tell-image-captioning-open.html Parsey McParseface https://research.googleblog.com/2016/05/announcing-syntaxnet-worlds-most.html Translation https://research.googleblog.com/2016/09/a-neural-network-for-machine.html Summarization https://research.googleblog.com/2016/08/text-summarization-with-tensorflow.html Pathology https://research.googleblog.com/2017/03/assisting-pathologists-in-detecting.html
  • 28. #WTMIndia BuildingModels CONSTRUCTION PHASE ● Assembles the graph ● Define the computation graph ○ Input, Operations, Output EXECUTION PHASE ● Executes operations in the graph ● Run Session ○ Execute graph and fetch output Tensorflow programs are generally structured into two phases.
  • 29. #WTMIndia Build a graph; then run it. ... c = tf.add(a, b) ... session = tf.Session() value_of_c = session.run(c, {a=1, b=2}) add a b c TensorFlow separates computation graph construction from execution.
  • 31. #WTMIndia Code Demos Hello World Matrix Multiplication Character recognition Fun experiments
  • 32. #WTMIndia Let’s dive deep into code - Hello World! import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print sess.run(hello) Tell the compiler that you want to use all functionalities that come with the tensorflow package. Create a constant op. This op is added as a node to the default graph. Start a session. Run the operation and get the result. Source : https://github.com/lakshya90/wwc-workshop/blob/master/hello_world.py
  • 33. #WTMIndia Let’s try Matrix Multiplication in TF import tensorflow as tf matrix1 = tf.constant([[3, 3]]) matrix2 = tf.constant([[2],[2]]) product = tf.matmul(matrix1, matrix2) Tell the compiler that you want to use all functionalities that come with the tensorflow package. Create a constant op that produces a 1x2 matrix. The op is added as a node to the default graph.The value returned by the constructor represents the output of the Constant op. Create another constant that produces a 2x1 matrix. Create a matmul op that takes 'matrix1' and 'matrix2' as inputs. The returned value, 'product', represents the result of the matrix multiplication. CONSTRUCTION PHASE Source : https://github.com/lakshya90/wwc-workshop/blob/master/mat_mul.py
  • 34. #WTMIndia Trying Matrix Multiplication in TF sess = tf.Session() result = sess.run(product) print(result) sess.close() Launch the default graph. To run the matmul op we call the session 'run()' method, passing 'product' which represents the output of the matmul op. This indicates to the call that we want to get the output of the matmul op back. All inputs needed by the op are run automatically by the session. They typically are run in parallel. The call 'run(product)' thus causes the execution of three ops in the graph: the two constants and matmul. The output of the op is returned in 'result' as a numpy `ndarray` object. ==> [[ 12]] Close the Session when we are done. EXECUTION PHASE Source : https://github.com/lakshya90/wwc-workshop/blob/master/mat_mul.py
  • 35. #WTMIndia What do we know so far ? ● Represents computations as graphs. ● Executes graphs in the context of Sessions. ● Represents data as tensors. ● Maintains state with Variables. ● Uses feeds and fetches to get data into and out of arbitrary operations.
  • 37. What we see What the computer “sees” #WTMIndia
  • 38. Difficult without Machine Learning def classify (pixels): # handwritten rules ... # ... # ... return 8 An image of a handwritten digit #WTMIndia
  • 40. import tensorflow as tf mnist = tf.contrib.learn.datasets.load_dataset('mnist') Images Labels 5 0 4 1 9 2 MNIST #WTMIndia
  • 41. Training data Testing data training_data = mnist.train.images training_labels = mnist.train.labels testing_data = mnist.test.images testing_labels = mnist.test.labels #WTMIndia
  • 42. Classifier Training data Testing data classifier = tf.learn.LinearClassifier(n_classes=10) #WTMIndia
  • 43. classifier = tf.learn.LinearClassifier(n_classes=10) ... ... 0 1 2 9 28x28 pixels 784 pixels Connect each input to each output #WTMIndia
  • 44. ... ... 0 1 2 9 Weights w1,0 w1,1 w1,2 w1,9 28x28 pixels 784 pixels classifier = tf.learn.LinearClassifier(n_classes=10) #WTMIndia
  • 45. Fully connected ... ... 0 1 2 9 28x28 pixels 784 pixels classifier = tf.learn.LinearClassifier(n_classes=10) #WTMIndia
  • 46. ... ... 0 1 2 9 28x28 pixels 784 pixels classifier = tf.learn.LinearClassifier(n_classes=10) WeightInput #WTMIndia
  • 49. Training data Testing data Output: a prediction “1” Input: an image #WTMIndia
  • 50. Training data Testing data Output: “8” Input: an image #WTMIndia
  • 51. score = metrics.accuracy_score(mnist.test.labels, classifier.predict(mnist.test.images)) ... ... 0 1 2 9 28x28 pixels 784 pixels actual label predicted label #WTMIndia
  • 52. score = metrics.accuracy_score(mnist.test.labels, classifier.predict(mnist.test.images)) ... ... 0 1 2 9 92% accuracy Is this good? 28x28 pixels 784 pixels #WTMIndia
  • 53. #WTMIndia Using TensorFlow on MNIST import numpy as np import tensorflow as tf import tf.contrib.learn as learn mnist = learn.datasets.load_dataset('mnist') data = mnist.train.images labels = np.asarray(mnist.train.labels, dtype=np.int32) test_data = mnist.test.images test_labels = np.asarray(mnist.test.labels, dtype=np.int32) feature_columns = learn.infer_real_valued_columns_from_input(data) classifier = learn.LinearClassifier(feature_columns=feature_columns, n_classes=10) classifier.fit(data, labels, batch_size=100, steps=1000) classifier.evaluate(test_data, test_labels) print classifier.evaluate(test_data, test_labels)["accuracy"] Import required libraries Import the dataset Fit a linear classifier Evaluate accuracy Source : https://github.com/lakshya90/wwc-workshop/blob/master/mnist.py
  • 54. ... ... 0 1 2 9 {Hidden layers #WTMIndia
  • 55. import tensorflow as tf mnist = tf.contrib.learn.datasets.load_dataset('mnist') classifier = tf.learn.DNNClassifier(n_classes=10, hidden_units[1024,512,256) classifier.fit(mnist.train.images, mnist.train.labels) score = metrics.accuracy_score(mnist.test.labels, classifier.predict(mnist.test.images)) print('Accuracy: {0:f}'.format(score)) #WTMIndia
  • 56. #WTMIndia Using TensorFlow on MNIST import numpy as np import tensorflow as tf import tf.contrib.learn as learn mnist = learn.datasets.load_dataset('mnist') data = mnist.train.images labels = np.asarray(mnist.train.labels, dtype=np.int32) test_data = mnist.test.images test_labels = np.asarray(mnist.test.labels, dtype=np.int32) feature_columns = learn.infer_real_valued_columns_from_input(data) classifier = learn.DNNClassifier(feature_columns=feature_columns, n_classes=10, hidden_units = [1024,512,256]) classifier.fit(data, labels, batch_size=100, steps=1000) classifier.evaluate(test_data, test_labels) print classifier.evaluate(test_data, test_labels)["accuracy"] Import required libraries Import the dataset Fit a linear classifier Evaluate accuracy Source : https://github.com/lakshya90/wwc-workshop/blob/master/mnist_DNN.py
  • 59.
  • 60. #WTMIndia What Does A.I. Have To Do With This Selfie? #WTMIndia
  • 61. ● Step 1 : Get the content and style image. ● Step 2 : Import the neural_style.py, stylize.py and vgg.py file. Ensure the mat file is present in your top level directory. ○ https://github.com/lakshya90/wwc-workshop, https://goo.gl/2hck1z ● Step 3 : Get your style transferred image. ○ python neural_style.py --content <content-file> --styles <style-file> --output <output-file> Try them out - goo.gl/fyDxhC #WTMIndia Source : https://github.com/lakshya90/wwc-workshop/tree/master/style_transfer
  • 62. #WTMIndia Challenge Push your code to GITHUB https://guides.github.com/activities/hello-world/ http://rogerdudler.github.io/git-guide/ RESOURCES : https://github.com/lakshya90/wwc-workshop
  • 63. Lots of tutorials at tensorflow.org #WTMIndia
  • 64. Codelab - goo.gl/xGsB9d Video - goo.gl/B2zYWN TensorFlow for Poets #WTMIndia
  • 65. tensorflow.org github.com/tensorflow Want to learn more? Udacity class on Deep Learning, goo.gl/iHssII Guides, codelabs, videos MNIST for Beginners, goo.gl/tx8R2b TF Learn Quickstart, goo.gl/uiefRn TensorFlow for Poets, goo.gl/bVjFIL ML Recipes, goo.gl/KewA03 TensorFlow and Deep Learning without a PhD, goo.gl/pHeXe7 Next steps #WTMIndia