Getting Started with TensorFlow 2.0 (Google I/O'19)

https://www.youtube.com/watch?v=lEljKc9ZtU8&list=PLOU2XLYxmsILVTiOlMJdo7RQS55jYhsMi&index=82&t=0s

"For Beginners":

  • TensorFlow Keras Sequential model etc unchanged from TF1
  • model is a data structure (layers) which can be checked for consistency internally, reducing programming errors

"For Experts":

  • TF2 adds "Model subclassing" - feels like obj oriented numpy dev
  • extend model class with your model
  • constructor ( init ) defines your layers
  • call() method defines forward pass

Training both types of models:

  • model.fit()
  • tf.GradientTape to compute generate gradients, subsequently use to optimize

Distributed Training "greatly simplified in TF2"

  • strategy = tf.mirroredStrategy()
  • with strategy.scope()
  • ....

80ish TF Projects on Guthub

  • TF Probability - Bayesian Modeling
  • TF Agents - RL
  • TF Text
  • TF Ranking
  • TF Privacy / TF Federated - secturity & privacy
  • Tensor2Tensor - available models for all applications https://github.com/tensorflow/tensor2tensor
  • ...

Deep Learning

  • Forward and backward pass = all matrix multiplication
  • Automatic differentiation - symbolic math is compiled to a graph

Using TF2 Like Numpy

In [1]:
import tensorflow as tf

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)
In [2]:
print(type(b))
print(type(b.numpy()))
<class 'tensorflow.python.framework.ops.EagerTensor'>
<class 'numpy.ndarray'>

Autograph

In [ ]:
 
In [ ]: