Recommended techniques to employ for idiomatic TF 2.0

The first recommendation concerns dealing with a general code workflow in TF 2.0. A common workflow in TF 1.x was to use a waterfall strategy, where all of the computations were laid out onto the default graph. Then, selected tensors were run using In TF 2.0, code should be refactored into smaller functions that will be called as needed. These functions can be normal Python functions and can still be run in graph mode if they're called inside another function annotated with tf.function. This means that tf.function should only be used to annotate high-level computations, such as the forward pass of a model or a single training step.

Previously, all of the computations that ...

Get What's New in TensorFlow 2.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.