Converting TF 1.x models

The first step is to replace all tf.Session.run() calls with a Python function. This means turning tf.placeholder and feed_dict into function arguments. These become the function's return value. This change means that standard Python tools such as pdb can be used to step through and debug the function, unlike TF 1.x. Once the function has been built, the tf.function annotation can be added to run the function in graph mode, along with the efficiency of the equivalent tf.Session.run calls in TF 1.x.

TF 1.x models that are created using the tf.layers API can be converted into TF 2.0 with relative ease. The tf.layers module was used to contain layer functions that relied on tf.variable_scope to define and reuse variables. ...

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.