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
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.
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
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
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
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.
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.
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
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