SlideShare a Scribd company logo
Tensorflow meetup
09 Oct 2018, Ghent
- First week of February (to be announced)
- Topics: TF 2.0 - TF probability - ?
- Speakers: ?
Next time
We are
hiring!
Today
Keras
Stijn Decubber @sdcubber
PyTorch
Xander Steenbrugge @xsteenbrugge
TensorFlow.js
Simon Plovyt
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Deep Learning for Humans
@fchollet, Keras author
“High-level neural networks API, capable of running on multiple
backends … focus on fast experimentation and being able to go
from idea to result with the least possible delay”
https://youtu.be/dfQ8lZ9dTjs
“A deep learning frontend”
Guiding principles
User friendly!
Simple & consistent APIs
Modular
Easily extensible
- Sequential api
- Functional api
- Source code
‘Power scores’ = aggregation of job listings, online articles, github activity, arxiv mentions. Source:
https://towardsdatascience.com/deep-learning-framework-power-scores-2018-23607ddf297a
Sequential API
Models are linear stacks of Layers
First layer requires an input shape
Layers are the core building blocks of keras models
Sequential API
Visualizing models
The batch dimension doesn’t matter
Training the model
In-memory data: numpy arrays
Training the model
In-memory data: numpy arrays
Training the model
Using validation data
Running inference
Returns a np array of predictions
Training the model
Out-of-memory data: with generators
Best practice is to subclass the Sequence object, which allows for safe multiprocessing
__getitem__ method yields data in batches
__len__ required to calculate no of batches/epoch
Training the model
Out-of-memory data: with generators
See stackoverflow and github for code
Common use case: out-of-memory image data
Read images from disk on the fly
Callbacks
Enhancing the training loop
Callback = an object that implements specific logic and is called by the model at various points during training
Keras provides callbacks for early stopping, learning rate scheduling, tensorboard, model saving...
Saving and Restoring Models
Saving and Restoring Models
Functional API
For complex architectures
Sequential API: linear stacks of layers
Functional API: DAG wrapped in a Keras model
Layers are called on previous layers
Functional API
For complex architectures
Specify inputs
Multiple outputs
Functional API
For complex architectures
Functional API
For complex architectures
Define a layer once
Call it twice
Wrap arbitrary TF operations in a
Lambda layer
Call it twice
Functional API
For complex architectures
Define a layer once
Call it twice
Wrap arbitrary TF operations in a
Lambda layer
Call it twice
Full flexibility
Activations, Losses and Optimizers
Full flexibility
Activations, Losses and Optimizers
Full flexibility
Activations, Losses and Optimizers
Full flexibility
Ultimate flexibility: subclass source code
See https://stackoverflow.com/questions/51874695/early-stop-when-validation-loss-satisfies-certain-criteria/51875492#51875492
Full flexibility
Ultimate flexibility: subclass source code
See https://stackoverflow.com/questions/51874695/early-stop-when-validation-loss-satisfies-certain-criteria/51875492#51875492
Solution: subclass
Keras’ EarlyStopping
Callback and implement
custom logic
Full flexibility
Ultimate flexibility: subclass source code
See https://stackoverflow.com/questions/51874695/early-stop-when-validation-loss-satisfies-certain-criteria/51875492#51875492
Solution: subclass
Keras’ EarlyStopping
Callback and implement
custom logic
callbacks = [MyCallBack(threshold=0.001, min_epochs=10, verbose=1)]
model.fit(features, labels, validation_data=(validation_feat, validation_labels),
callbacks=callbacks, epochs=100)
Pretrained models
Transfer learning & model finetuning
Pretrained models
Transfer learning & model finetuning
model = ResNet50(weights= 'imagenet')
preds = model.predict(x)
model = VGG16(weights= 'imagenet', include_top=False)
features = model.predict(x)
Directly use a model
Extract convolutional
features
base_model = VGG19(weights= 'imagenet')
model = Model(inputs=base_model.input,
outputs=base_model.get_layer('block4_pool').output)
block4_pool_features = model.predict(x)
Extract features at any
level of the model
Functional API: DAG wrapped in a Keras model
# create the base pre-trained model
base_model = InceptionV3(weights= 'imagenet', include_top= False)
# add a global spatial average pooling layer
x = base_model.output
x = GlobalAveragePooling2D()(x)
# let's add a fully-connected layer
x = Dense(1024, activation='relu')(x)
# and a logistic layer -- let's say we have 200 classes
predictions = Dense( 200, activation='softmax')(x)
# this is the model we will train
model = Model(inputs=base_model.input, outputs=predictions)
Pretrained models
Transfer learning & model finetuning
Reuse model base, put
custom classifier on top
Tensorflow integration: tf.keras
TensorFlow 2.0 will rely heavily on its Keras integration as thé high level API to use
● comprises full Keras API
● Better integration with TF features:
estimators, dataset API…
● Fully compatible with TF serving: build
& train with Keras, productionize with
TF serving
● current best practice
See https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
Only in tf.keras
Source: https://www.youtube.com/watch?v=dfQ8lZ9dTjs
See https://medium.com/tensorflow/training-and-serving-ml-models-with-tf-keras-fd975cc0fa27
Getting started
● Guides and examples at https://keras.io
● Stackoverflow
● End-to-end example blogpost with tf.Keras:
https://medium.com/tensorflow/training-and-servin
g-ml-models-with-tf-keras-fd975cc0fa27
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
46 ● Came out of the “Torch” framework, which was used at DeepMind before
TensorFlow came along
● → support for Python instead of Lua led to “PyTorch”
● Shared support from:
Pytorch History
47
The Computation Graph
Deep Learning libraries usually have 2 interpreters:
1. Host language (eg Python)
2. The computation graph (eg C++ backbone)
Can then be optimized and run in parallel on a GPU
48
The Static Computation Graph
49
Dynamic Computation Graph (~ Chainer and Dynet)
50
Static Computation Graph
51
Dynamic Computation Graph
52
→ Automatically runs the operation in the graph and fetches the current values & type
Pytorch Printing
53
Feels exactly like...
54
Feels exactly like...
55
Dynamic Computation Graph
“In TensorFlow you define graph statically before a model can run.
Communication with the outer world is performed via tf.Session
object and tf.Placeholder which will be substituted by external data at
runtime. When you write in TensorFlow sometimes you feel that your
model is behind a brick wall with several tiny holes to communicate
over.
In PyTorch things are more imperative and dynamic: you can define,
change and execute nodes as you go, no special session interfaces
or placeholders. Overall, the framework is more tightly integrated
with Python language and feels more native most of the times.“
56
57
Dynamic Computation Graph
58
Dynamic Computation Graph
59
Dynamic Computation Graph
Flexible gradient computation across multiple subgraphs
60
Explicit control over the backpropagation process:
61
62
Fine-tuning is God Damn Easy!
63
Easy data augmentation at runtime:
64
Easily customize model pipelines:
VAE
encoder
VAE
decoder
Latent
Encoding
Input
Data
65
Easily customize model pipelines:
VAE
encoder
VAE
decoder
Latent
Encoding
Some
other
Model
pipeline
Labels
Input
Data
66
Easily customize model pipelines:
67
Intuitive Numpy integration:
68
Running your code on GPU requires ZERO changes
69
Saving and restoring models
Saving and Loading models is waaaay less of a hassle compared to TF
● No meta_graph, index, graph_def, session, ...
● Load a model in a single line:
70
Saving and restoring models
Saving and Loading models is waaaay less of a hassle compared to TF
● No meta_graph, index, graph_def, session, ...
● Load a model in a single line:
71
But I need everything...
72
Let’s talk speed
Training Time
(lower = better)
ResNet50 VGG16 VGG19
73
Let’s talk user base (Feb 2018)
74
Let’s talk Cloud Integration
75
Varia
● PyTorch easily integrates with TensorBoard!
TensorBoard is just great…
● Since computation graphs in PyTorch are defined at
runtime you can use your favorite Python debugging tools
such as pdb, ipdb, PyCharm debugger or old trusty print
statements :)
76
Some of the big guys are already on board...
77
Some of the big guys are already on board...
78
One of PyTorch’s biggest strengths is its first-class Python integration, imperative style, simplicity of
the API and options. These are aspects that make PyTorch good for research and hackability.
One of its biggest downsides has been production-support. What we mean by production-support is
the countless things one has to do to models to run them efficiently at massive scale:
● exporting to C++-only runtimes for use in larger projects
● optimizing mobile systems on iPhone, Android, Qualcomm and other systems
● using more efficient data layouts and performing kernel fusion to do faster inference
(saving 10% of speed or memory at scale is a big win)
● quantized inference (such as 8-bit inference)
1.0
79 Growing Cloud Service support:
1.0
80
“OMG I just read this cool new paper and they
have an implementation in …”
“Great! I’ll be able to run this code
easily in a distributed training setup
and serve it to thousands of
customers through an API with
tf.serving”
“Great! I’ll be able to dive into the
code, figure out how it works and
easily tweak the entire codebase into
something I can use!”
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
nothing less than
Any application that can be written in JavaScript
will eventually be written in JavaScript.
Jeff Atwood (co-founder StackOverflow.com)
11 years ago
Just another language?
[ python meetup ] [ javascript meetup ]
Just another language?
The complete picture
→ popularity amongst developers on Stackoverflow → amount of code written (GitHub)
Just another language?
In terms of Machine Learning
source: State of the Developer (Q1 2017) – Machine Learning Languages Shootout
Why TensorFlow.js?
TF.js is more than just TF in JavaScript
Why TensorFlow.js?
Machine Learning in the browser
Server
Browser
Why TensorFlow.js?
No drivers or installs required
It just works! No ‘install’ difference with server-side ML.
GPU acceleration is available through WebGL
Highly interactive playground.tensorflow.com
Why TensorFlow.js?
Perfect for transfer learning
Hard to train entire models, but tuning is very feasible.
MobileNetPoseNet
freshtilledsoil.com
Why TensorFlow.js?
Easily generalizable to edge devices
No major adjustments required to provide functionality.
Direct access to sensor data
New applications involving camera, microphone and accelerometer.
Accelerometer
Camera
Microphone
Location
Why TensorFlow.js?
Eliminating server-side processing
Model has to be downloaded once, but is cached afterwards.
Feedback is still possible, e.g. by exchanging
model weights (“memory”).
Why TensorFlow.js?
Eliminating server-side processing
Eliminate data flow. No input data needs to be sent back and forth
Low latency, near instant results.
Huge savings in server costs.
Why TensorFlow.js?
Enables the usage of private data
Enables tuning the model with private data.
The resulting weights can still be stored.
No concerns as the data is not exchanged.
Models can always be used in offline mode.
No need for central data storage.
Performance Data Medical Data Conversation Data Financial Data Contact Data Media
Why TensorFlow.js?
Future applications
Possibilities for Browser Extensions & Plug-ins
Encryption
Website accessibility
Text autocompletion
Applications for edge devices
ML frameworks for Web Developers (with low latency)
Recommender systems
Website-specific context generation
Voice controlled search engines or assistants
Why TensorFlow.js?
Easy model conversion:
Easy model importing:
source: Nikhil Thorat and Daniel Smilkov @ TensorFlow Dev Summit 2018
Why TensorFlow.js?
Good
Great
Summary
A tiny bit of JavaScript versus
Low latency predictions
Privacy guarantees
Avoiding data flow and
elimination of server costs
New applications
TensorFlow meetup: Keras - Pytorch - TensorFlow.js

More Related Content

What's hot (20)

PDF
Graal and Truffle: One VM to Rule Them All
Thomas Wuerthinger
 
PDF
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
Animesh Singh
 
PDF
A Library for Emerging High-Performance Computing Clusters
Intel® Software
 
PDF
Use C++ and Intel® Threading Building Blocks (Intel® TBB) for Hardware Progra...
Intel® Software
 
PPTX
JVM++: The Graal VM
Martin Toshev
 
PDF
From Python to PySpark and Back Again – Unifying Single-host and Distributed ...
Databricks
 
PDF
Hyper-Parameter Tuning Across the Entire AI Pipeline GPU Tech Conference San ...
Chris Fregly
 
PDF
PipelineAI Continuous Machine Learning and AI - Rework Deep Learning Summit -...
Chris Fregly
 
PDF
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on GPUs
Chris Fregly
 
PDF
Transparent GPU Exploitation for Java
Kazuaki Ishizaki
 
PDF
MLFlow 1.0 Meetup
Databricks
 
PPTX
JVM and OS Tuning for accelerating Spark application
Tatsuhiro Chiba
 
PDF
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Chris Fregly
 
PDF
Backend.AI Technical Introduction (19.09 / 2019 Autumn)
Lablup Inc.
 
PDF
Kubeflow Distributed Training and HPO
Animesh Singh
 
PDF
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Intel® Software
 
PDF
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Chris Fregly
 
PPTX
ONNX - The Lingua Franca of Deep Learning
Hagay Lupesko
 
PDF
PipelineAI Real-Time Machine Learning - Global Artificial Intelligence Confer...
Chris Fregly
 
PDF
Towards JVM Dynamic Languages Toolchain
Attila Szegedi
 
Graal and Truffle: One VM to Rule Them All
Thomas Wuerthinger
 
End to end Machine Learning using Kubeflow - Build, Train, Deploy and Manage
Animesh Singh
 
A Library for Emerging High-Performance Computing Clusters
Intel® Software
 
Use C++ and Intel® Threading Building Blocks (Intel® TBB) for Hardware Progra...
Intel® Software
 
JVM++: The Graal VM
Martin Toshev
 
From Python to PySpark and Back Again – Unifying Single-host and Distributed ...
Databricks
 
Hyper-Parameter Tuning Across the Entire AI Pipeline GPU Tech Conference San ...
Chris Fregly
 
PipelineAI Continuous Machine Learning and AI - Rework Deep Learning Summit -...
Chris Fregly
 
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on GPUs
Chris Fregly
 
Transparent GPU Exploitation for Java
Kazuaki Ishizaki
 
MLFlow 1.0 Meetup
Databricks
 
JVM and OS Tuning for accelerating Spark application
Tatsuhiro Chiba
 
Smokey and the Multi-Armed Bandit Featuring BERT Reynolds Updated
Chris Fregly
 
Backend.AI Technical Introduction (19.09 / 2019 Autumn)
Lablup Inc.
 
Kubeflow Distributed Training and HPO
Animesh Singh
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Intel® Software
 
Optimize + Deploy Distributed Tensorflow, Spark, and Scikit-Learn Models on G...
Chris Fregly
 
ONNX - The Lingua Franca of Deep Learning
Hagay Lupesko
 
PipelineAI Real-Time Machine Learning - Global Artificial Intelligence Confer...
Chris Fregly
 
Towards JVM Dynamic Languages Toolchain
Attila Szegedi
 

Similar to TensorFlow meetup: Keras - Pytorch - TensorFlow.js (20)

PPTX
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
PDF
TensorFlow and Keras: An Overview
Poo Kuan Hoong
 
PDF
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
PDF
Tensor flow 2.0 what's new
Poo Kuan Hoong
 
PPTX
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
PPTX
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
PDF
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
PyData
 
PDF
Reproducible AI using MLflow and PyTorch
Databricks
 
PPTX
Keras_Core_introduction.pptx
GDSCBBIT
 
PDF
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
Databricks
 
PDF
Neural Networks from Scratch - TensorFlow 101
Gerold Bausch
 
PDF
The Flow of TensorFlow
Jeongkyu Shin
 
PDF
OpenPOWER Workshop in Silicon Valley
Ganesan Narayanasamy
 
PDF
Introduction to TensorFlow 2.0
Databricks
 
PDF
Overview of TensorFlow For Natural Language Processing
ananth
 
PDF
Tensor flow white paper
Ying wei (Joe) Chou
 
PPTX
190111 tf2 preview_jwkang_pub
Jaewook. Kang
 
PDF
Pytorch A Detailed Overview Agladze Mikhail
ilzobrzan47
 
PPTX
Soumith Chintala - Increasing the Impact of AI Through Better Software
MLconf
 
PPTX
slide-keras-tf.pptx
RithikRaj25
 
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
TensorFlow and Keras: An Overview
Poo Kuan Hoong
 
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
Tensor flow 2.0 what's new
Poo Kuan Hoong
 
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
PyData
 
Reproducible AI using MLflow and PyTorch
Databricks
 
Keras_Core_introduction.pptx
GDSCBBIT
 
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
Databricks
 
Neural Networks from Scratch - TensorFlow 101
Gerold Bausch
 
The Flow of TensorFlow
Jeongkyu Shin
 
OpenPOWER Workshop in Silicon Valley
Ganesan Narayanasamy
 
Introduction to TensorFlow 2.0
Databricks
 
Overview of TensorFlow For Natural Language Processing
ananth
 
Tensor flow white paper
Ying wei (Joe) Chou
 
190111 tf2 preview_jwkang_pub
Jaewook. Kang
 
Pytorch A Detailed Overview Agladze Mikhail
ilzobrzan47
 
Soumith Chintala - Increasing the Impact of AI Through Better Software
MLconf
 
slide-keras-tf.pptx
RithikRaj25
 
Ad

Recently uploaded (20)

PDF
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
PPTX
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PPTX
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
Linux schedulers for fun and profit with SchedKit
Alessio Biancalana
 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
Talbott's brief History of Computers for CollabDays Hamburg 2025
Talbott Crowell
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
Role_of_Artificial_Intelligence_in_Livestock_Extension_Services.pptx
DrRajdeepMadavi
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
Ad

TensorFlow meetup: Keras - Pytorch - TensorFlow.js