Automatically converting Python code into its graphical representation is done with the use of AutoGraph. In TensorFlow 2.0, AutoGraph is automatically applied to a function when it is decorated with @tf.function. This decorator creates callable graphs from Python functions.

A function, once decorated correctly, is processed by tf.function and the tf.autograph module in order to convert it into its graphical representation. The following diagram shows a schematic representation of what happens when a decorated function is called:

Schematic representation of what happens when a function, f, decorated with @tf.function, which is called ...

Get Hands-On Neural Networks with 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.