The release of TensorFlow 2.0 comes with a significant number of improvements over its 1.x version, all with a focus on ease of usability and a better user experience. We will give an overview of what TensorFlow 2.0 is and discuss how to get started building models from scratch using TensorFlow 2.0’s high-level api, Keras. We will walk through an example step-by-step in Python of how to build an image classifier. We will then showcase how to leverage a transfer learning to make building a model even easier! With transfer learning, we can leverage other pretrained models such as ImageNet to drastically speed up the training time of our model. TensorFlow 2.0 makes this incredibly simple to do.
15. You have lots of data (~ 10k+ examples)
Use Deep Learning When...
16. You have lots of data (~ 10k+ examples)
The problem is “complex” - speech, vision, natural language
Use Deep Learning When...
17. You have lots of data (~ 10k+ examples)
The problem is “complex” - speech, vision, natural language
The data is unstructured
Use Deep Learning When...
18. You have lots of data (~ 10k+ examples)
The problem is “complex” - speech, vision, natural language
The data is unstructured
You need the absolute “best” model
Use Deep Learning When...
19. You don’t have a large dataset
Don’t Use Deep Learning When...
20. You don’t have a large dataset
You are performing sufficiently well with traditional ML methods
Don’t Use Deep Learning When...
21. You don’t have a large dataset
You are performing sufficiently well with traditional ML methods
Your data is structured and you possess the proper domain knowledge
Don’t Use Deep Learning When...
22. You don’t have a large dataset
You are performing sufficiently well with traditional ML methods
Your data is structured and you possess the proper domain knowledge
Your model should be explainable
Don’t Use Deep Learning When...
24. Open source deep learning library
Utilities to help you write neural networks
GPU / TPU support
Released by Google in 2015
>2200 Contributors
2.0 released September 2019
TensorFlow
34. Scalable
Tested at Google-scale.
Deploy everywhere
Easy
Simplified APIs.
Focused on Keras and
eager execution
Powerful
Flexibility and performance.
Power to do cutting edge research
and scale to > 1 exaflops
TensorFlow 2.0
38. import tensorflow as tf # Assuming TF 2.0 is installed
a = tf.constant([[1, 2],[3, 4]])
b = tf.matmul(a, a)
print(b)
# tf.Tensor( [[ 7 10] [15 22]], shape=(2, 2), dtype=int32)
print(type(b.numpy()))
# <class 'numpy.ndarray'>
You can use TF 2.0 like NumPy
43. Fast prototyping, advanced research, and production
keras.io = reference implementation
import keras
tf.keras = TensorFlow’s implementation (a superset, built-in to TF, no
need to install Keras separately)
from tensorflow import keras
Keras and tf.keras
51. Symbolic (For Beginners)
Your model is a graph of layers
Any graph you compile will run
TensorFlow helps you debug by catching errors at compile time
Symbolic vs Imperative APIs
52. Symbolic (For Beginners)
Your model is a graph of layers
Any graph you compile will run
TensorFlow helps you debug by catching errors at compile time
Imperative (For Experts)
Your model is Python bytecode
Complete flexibility and control
Harder to debug / harder to maintain
Symbolic vs Imperative APIs
56. @tf.function
def f(x):
while tf.reduce_sum(x) > 1:
x = tf.tanh(x)
return x
# you never need to run this (unless curious)
print(tf.autograph.to_code(f))
AutoGraph makes this possible
57. def tf__f(x):
def loop_test(x_1):
with ag__.function_scope('loop_test'):
return ag__.gt(tf.reduce_sum(x_1), 1)
def loop_body(x_1):
with ag__.function_scope('loop_body'):
with ag__.utils.control_dependency_on_returns(tf.print(x_1)):
tf_1, x = ag__.utils.alias_tensors(tf, x_1)
x = tf_1.tanh(x)
return x,
x = ag__.while_stmt(loop_test, loop_body, (x,), (tf,))
return x
Generated code
75. Intro to TensorFlow
for Deep Learning
Introduction to TensorFlow
for AI, ML and DL
coursera.org/learn/introduction-tensorflow udacity.com/tensorflow
New Courses