Machine
Learning
with
TensorFlow
By Sarah Stemmler
About me
log@sarahstemmler.de
maxi_likelihood
Agenda
• What is TensorFlow?
• Get into Machine & Deep Learning
• Hands on: Computer Vision in TensorFlow
• 🎁
• What Else to Know about TensorFlow?
• Question & Answers
What is
TensorFlow?
Summary
• Open-source framework to perform Machine and Deep
Learning
• A backend for large numeric computations
• Basic concepts are tensors and graphs
• For CPU, GPU, TPU*
• C++ in the backend
https://www.tensorflow.org/ * Tensor Processing Unit
Tensors
1
2
3
4
5
1 2
2 3
3 4
4 5
5 6
1 1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
Multi-dimensional arrays
• All TensorFlow computations are represented as graphs
• Nodes are operations
• Edges are tensors
• First: construction of graph
• Second: Executed in a session
Flow graph
C
A B
Add
MatMul
…
It’s All about Usability!
TensorFlow 2.0
• Full integration of Keras library as high-level API
• API Cleanup
• Functions instead of sessions
• Eager execution for a pythonic programming style
• Upgrade script provided on TF website
Under the Hood
Keras
Tensorflow
CUDA / cuDNN
GPU
BLAS, Eigen
CPU
If TensorFlow is
executed on CPU it
comes with a tensor
operation library
called Eigen
NVIDIA CUDA Deep
Neural Network
Library is extremely
efficient on a GPU
Under the Hood
Keras
Tensorflow
CUDA / cuDNN
GPU
BLAS, Eigen
CPU
If TensorFlow is
executed on CPU it
comes with a tensor
operation library
called Eigen
NVIDIA CUDA Deep
Neural Network
Library is extremely
efficient on a GPU
Development Ecosystem
tf.data,
numpy
Loading and
pre-processing
Build, train &
reuse models
DeployDevelopment
Tools
Tensor
Board
TF
Hub
https://keras.io/
Use Cases
Text Speech Image Audio Content
Summarization
Sentiment Analysis
Classification
Recognition
Speech to Text
Text to Speech
Clustering
Object Detection
Gesture
Recognition
Facial Modelling
Translation
Clustering
Video Generation
Text Generation
Audio Generation
Use Cases
Text Speech Image Audio Content
Summarization
Sentiment Analysis
Classification
Recognition
Speech to Text
Text to Speech
Clustering
Object Detection
Gesture
Recognition
Facial Modelling
Translation
Clustering
Video Generation
Text Generation
Audio Generation
TensorFlow at
https://www.airbnb.de/
Get into
Machine & Deep
Learning
Machine Learning
Extract knowledge from data
Build a generalised model
Supervised
Learning
Approach
Goal
Types
Unsupervised
Learning
Reinforcement
Learning
Unsupervised Machine Learning
• Algorithms draw conclusions on
the data without human input
• Find hidden patterns and
structures in data that are yet
unknown
• e.g. Clustering
Supervised vs. Unsupervised
Supervised Machine Learning
• “Teaching the model with
knowledge”
• Provide algorithm with labelled
training data (e.g. correct classes)
and features (input data)
• Classification and Regression
Example for Classification
% Leather Heel Gender Shoe Type
45 TRUE Female Pumps
81 FALSE Male Sneaker
71 TRUE Female Sneaker
50 FALSE Female Pumps
Training
65 FALSE Female ?
Prediction
Model Training and Evaluation
• Split data into training and
test set
• Run for pre-defined iterations
(= epochs)
• Test set to evaluate model
• Model learns from errors and
can be improved
• Goal: Find the minim error
between actual and predicted
values (e.g. Accuracy)
Training
Test
Prediction
Score
Over- and Underfitting
Overfitting
• The model learns too much from
the training data
• No generalisation of model
• Bad performance on test data
Underfitting
• Training data does not contain full
information of whole dataset
• Model cannot learn patterns
• Bad performance on training and
test data
Deep Learning = Neural Networks
Input Layer Hidden Layers Output Layer
Input data
in form of
features /
tensors
Output can
be a class or
a numeric
value
Weights Weights Weights
Training of a Neural Network
X1
X2
X3
SUM Activation function SUM
Threshold
w1,1
w2,1
w3,1
Input Layer Hidden Layers Output Layer
Activation Functions
Activation functions are attached to each neuron (node) and decide
whether it should be activated (fired) or not
Step Function Sigmoid ReLu
Loss Function & Optimizer
• Train weights and evaluate prediction with actual values of test set
• Goal: Find model with minimal error
• Loss function: error function used for validation
• Uses gradient descent approach
• Optimizers: Algorithms that perform a gradient descent approach
• Algorithm in Neural Networks: Backpropagation
Hands on:
Computer Vision in
TensorFlow
How does a computer see?
RGB [0,255]Black & White [0,1]
1: white
0: black
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
1 2
2 3
3 4
4 5
5 6
Grayscale [0,255]
255: white
[1,254]: gray
0: black
Black & White picture
Grayscaled Picture
RGB Picture
“What are the most popular
datasets for cross-sectional
data?”
http://www.lac.inpe.br/~rafael.santos/Docs/CAP394/WholeStory-Iris.html
https://de.wikipedia.org/wiki/RMS_Titanic
MNIST Dataset
Demo
Convolutional Neural Network
Keep spatial information of pixels
• Low level features: edges
• Medium level features: circles,
squares
• High level features: faces, bodies
Convolutional Neural Networks
10x10x1
10x10x9
5x5x9
Conv Layer Pooling LayerInput Flatten Layer
100x1
Convolutional (Filter) Layer
Filter, kernel size, padding, stride
Pooling Layer
Demo
🎁
Too sexy?
What Else to Know
about
TensorFlow?
TensorBoard
https://www.tensorflow.org/tensorboard
TensorFlow Hub
https://tfhub.dev/
For desktop, mobile, web
To Production
Development
Production
https://www.tensorflow.org/tfx/tutorials/serving/rest_simple
Data
http request
Save and
serve model
TensorFlow
Extended
Play with Neural Networks
https://playground.tensorflow.org/
Wanna Learn more?
• Tutorials and docu at:
tensorflow.org & keras.io
• Udemy German course:
“Deep Learning, Neuronale
Netze und TensorFlow in
Python” by Jan Schaffranek
• Many more on Coursera,…
• Data Science Competitions:
kaggle.com
Thank you!
Questions &
Answers

Machine Learning with TensorFlow 2