Catalit LLC
TENSORFLOW 2.0 AND KERAS
Francesco Mosconi
These slides: bit.ly/odsc20190124
Data Weekends
Catalit
Data Science
Zero to
Deep Learning
Catalit LLC
ABOUT US
www.catalit.com
Data Weekends
Catalit
Data Science
Zero to
Deep Learning
www.dataweekends.com bootcamp.zerotodeeplearning.com
Catalit LLC
TODAY
• Changes inTensorflow 2.0
• How it differsTensorflow 1.*
• How it differs from keras.io
Catalit LLC
SOMETIME IN AUGUST 2018 …
Catalit LLC
KEY POINTS
• Public 2.0 design process
• Eager execution
• Remove deprecated APIs & reduce the amount of duplication
• Compatibility and continuity withTensorflow 1.x
• Compatibility with 1.x exported models
• No more tf.contrib
• More platforms and languages
Catalit LLC
TODAY
• Public 2.0 design process
• Eager execution
• Remove deprecated APIs & reduce the amount of duplication
• Compatibility and continuity withTensorflow 1.x
• Compatibility with 1.x exported models
• No more tf.contrib
• More platforms and languages
Catalit LLC
KEY POINTS
• Public 2.0 design process
• Eager execution
• Remove deprecated APIs & reduce the amount of duplication
• Compatibility and continuity withTensorflow 1.x
• Compatibility with 1.x exported models
• No more tf.contrib
• More platforms and languages
Catalit LLC
PUBLIC 2.0 DESIGN PROCESS
https://groups.google.com/a/tensorflow.org/forum/#!forum/discuss
https://github.com/tensorflow/community/blob/master/governance/TF-RFCs.md
https://github.com/tensorflow/community/tree/master/rfcs
Catalit LLC
WHAT IT MEANS FORYOU
• Release date not defined yet

=> rumored forTF Dev Summit (March 6-7, 2019)
• If you’re aTF 1.x developer

=> start updating your code as soon as RFPs are accepted
• There will be a conversion tool from 1.x to 2.0 (won’t be
perfect, but hey…)
Catalit LLC
KEY POINTS
• Public 2.0 design process
• Eager execution
• Remove deprecated APIs & reduce the amount of duplication
• Compatibility and continuity withTensorflow 1.x
• Compatibility with 1.x exported models
• No more tf.contrib
• More platforms and languages
Catalit LLC
EAGER EXECUTION
• Available since late 2017
• Following Pytorch and Chainer
• Imperative
• Define-by-run
• No static graph & session
Catalit LLC
EAGER EXECUTION
• Faster debugging with Python tools
• Dynamic models with Python control flow
• Support for custom and higher-order gradients
Catalit LLC
IS GRAPH GOING AWAY?
• No, you can still define models using the traditional
static graph approach
Catalit LLC
Standard Tensorflow
Catalit LLC
Standard Tensorflow
Eager Execution
Catalit LLC
Standard Tensorflow
Catalit LLC
Standard Tensorflow Eager Execution
Catalit LLC
Catalit LLC
WHAT IT MEANS FORYOU
• Debug like Numpy, scale likeTensorflow
• Easier to build and test custom models
• Slower than static graph mode
Catalit LLC
KEY POINTS
• Public 2.0 design process
• Eager execution
• Remove deprecated APIs & reduce the amount of duplication
• Compatibility and continuity withTensorflow 1.x
• Compatibility with 1.x exported models
• No more tf.contrib
• More platforms and languages
Catalit LLC
MODEL APIS INTF 1.X
• tf.core
• tf.layers
• tf.keras.layers
• tf.estimator.Estimator
• tf.contrib.learn.Estimator
• …
Catalit LLC
MODEL APIS INTF 2.0
• tf.core ====> Same
• tf.layers ====> Deprecated
• tf.keras.layers ====> Primary API
• tf.estimator.Estimator ====> API same, implementation changed to tf.keras
• tf.contrib.learn.Estimator ====> Deprecated
• …
Catalit LLC
MODEL APIS INTF 2.0
• tf.core ====> Same
• tf.layers ====> Deprecated
• tf.keras.layers ====> Primary API
• tf.estimator.Estimator ====> API same, implementation changed to tf.keras
• tf.contrib.learn.Estimator ====> Deprecated
• …
Catalit LLC
TF.KERAS
• What is it?
• How does it work?
• How does it differ from keras.io implementation?
Catalit LLC
WHAT IS KERAS?
https://towardsdatascience.com/deep-learning-framework-power-scores-2018-23607ddf297a
Catalit LLC
WHAT IS KERAS
• Keras is an API specification to design deep learning model
• https://keras.io/

=> independent reference implementation (usingTF or CNTK as backend)
• tf.keras

=>Tensorflow implementation of the same API spec
• Other frameworks implement some version of the API
Catalit LLC
MODEL DEFINITION IN KERAS
• Sequential API
• Functional API
• Model API
Catalit LLC
SEQUENTIAL API
Catalit LLC
SEQUENTIAL API
Catalit LLC
FUNCTIONAL API
Catalit LLC
MODEL API
Catalit LLC
DIFFERENCES
• Support for Eager Execution
• tf.dataVS python data generators
• Model Exporting
• Compatible with Feature Columns
• Compatible with Estimators
Catalit LLC
KEY POINTS
• Public 2.0 design process
• Eager execution
• Remove deprecated APIs & reduce the amount of duplication
• Compatibility and continuity with Tensorflow 1.x
• Compatibility with 1.x exported models
• No more tf.contrib
• More platforms and languages
Catalit LLC
bootcamp.zerotodeeplearning.com
March 25 - 29 San Francisco Bay Area
Catalit LLC
SEEYOU IN MAY …
Francesco Mosconi
@framosconis fm@catalit.com
bootcamp.zerotodeeplearning.com
Data Weekends
Catalit
Data Science
Zero to
Deep Learning

Tensorflow 2.0 and Keras ODSC Jan 2019

  • 1.
    Catalit LLC TENSORFLOW 2.0AND KERAS Francesco Mosconi These slides: bit.ly/odsc20190124 Data Weekends Catalit Data Science Zero to Deep Learning
  • 2.
    Catalit LLC ABOUT US www.catalit.com DataWeekends Catalit Data Science Zero to Deep Learning www.dataweekends.com bootcamp.zerotodeeplearning.com
  • 3.
    Catalit LLC TODAY • ChangesinTensorflow 2.0 • How it differsTensorflow 1.* • How it differs from keras.io
  • 4.
    Catalit LLC SOMETIME INAUGUST 2018 …
  • 5.
    Catalit LLC KEY POINTS •Public 2.0 design process • Eager execution • Remove deprecated APIs & reduce the amount of duplication • Compatibility and continuity withTensorflow 1.x • Compatibility with 1.x exported models • No more tf.contrib • More platforms and languages
  • 6.
    Catalit LLC TODAY • Public2.0 design process • Eager execution • Remove deprecated APIs & reduce the amount of duplication • Compatibility and continuity withTensorflow 1.x • Compatibility with 1.x exported models • No more tf.contrib • More platforms and languages
  • 7.
    Catalit LLC KEY POINTS •Public 2.0 design process • Eager execution • Remove deprecated APIs & reduce the amount of duplication • Compatibility and continuity withTensorflow 1.x • Compatibility with 1.x exported models • No more tf.contrib • More platforms and languages
  • 8.
    Catalit LLC PUBLIC 2.0DESIGN PROCESS https://groups.google.com/a/tensorflow.org/forum/#!forum/discuss https://github.com/tensorflow/community/blob/master/governance/TF-RFCs.md https://github.com/tensorflow/community/tree/master/rfcs
  • 9.
    Catalit LLC WHAT ITMEANS FORYOU • Release date not defined yet
 => rumored forTF Dev Summit (March 6-7, 2019) • If you’re aTF 1.x developer
 => start updating your code as soon as RFPs are accepted • There will be a conversion tool from 1.x to 2.0 (won’t be perfect, but hey…)
  • 10.
    Catalit LLC KEY POINTS •Public 2.0 design process • Eager execution • Remove deprecated APIs & reduce the amount of duplication • Compatibility and continuity withTensorflow 1.x • Compatibility with 1.x exported models • No more tf.contrib • More platforms and languages
  • 11.
    Catalit LLC EAGER EXECUTION •Available since late 2017 • Following Pytorch and Chainer • Imperative • Define-by-run • No static graph & session
  • 12.
    Catalit LLC EAGER EXECUTION •Faster debugging with Python tools • Dynamic models with Python control flow • Support for custom and higher-order gradients
  • 13.
    Catalit LLC IS GRAPHGOING AWAY? • No, you can still define models using the traditional static graph approach
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
    Catalit LLC WHAT ITMEANS FORYOU • Debug like Numpy, scale likeTensorflow • Easier to build and test custom models • Slower than static graph mode
  • 20.
    Catalit LLC KEY POINTS •Public 2.0 design process • Eager execution • Remove deprecated APIs & reduce the amount of duplication • Compatibility and continuity withTensorflow 1.x • Compatibility with 1.x exported models • No more tf.contrib • More platforms and languages
  • 21.
    Catalit LLC MODEL APISINTF 1.X • tf.core • tf.layers • tf.keras.layers • tf.estimator.Estimator • tf.contrib.learn.Estimator • …
  • 22.
    Catalit LLC MODEL APISINTF 2.0 • tf.core ====> Same • tf.layers ====> Deprecated • tf.keras.layers ====> Primary API • tf.estimator.Estimator ====> API same, implementation changed to tf.keras • tf.contrib.learn.Estimator ====> Deprecated • …
  • 23.
    Catalit LLC MODEL APISINTF 2.0 • tf.core ====> Same • tf.layers ====> Deprecated • tf.keras.layers ====> Primary API • tf.estimator.Estimator ====> API same, implementation changed to tf.keras • tf.contrib.learn.Estimator ====> Deprecated • …
  • 24.
    Catalit LLC TF.KERAS • Whatis it? • How does it work? • How does it differ from keras.io implementation?
  • 25.
    Catalit LLC WHAT ISKERAS? https://towardsdatascience.com/deep-learning-framework-power-scores-2018-23607ddf297a
  • 26.
    Catalit LLC WHAT ISKERAS • Keras is an API specification to design deep learning model • https://keras.io/
 => independent reference implementation (usingTF or CNTK as backend) • tf.keras
 =>Tensorflow implementation of the same API spec • Other frameworks implement some version of the API
  • 27.
    Catalit LLC MODEL DEFINITIONIN KERAS • Sequential API • Functional API • Model API
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
    Catalit LLC DIFFERENCES • Supportfor Eager Execution • tf.dataVS python data generators • Model Exporting • Compatible with Feature Columns • Compatible with Estimators
  • 33.
    Catalit LLC KEY POINTS •Public 2.0 design process • Eager execution • Remove deprecated APIs & reduce the amount of duplication • Compatibility and continuity with Tensorflow 1.x • Compatibility with 1.x exported models • No more tf.contrib • More platforms and languages
  • 34.
  • 35.
    Catalit LLC SEEYOU INMAY … Francesco Mosconi @framosconis fm@catalit.com bootcamp.zerotodeeplearning.com Data Weekends Catalit Data Science Zero to Deep Learning