TensorFlow 2 documentation for graph-mode

Viewed 471

When I check the TensorFlow documentation (Python API docs or guides), it all seems exclusively for eager-mode. Almost all the examples don't even mention this. For some specific operation/function like tf.nn.relu, this does not really make any difference. However, for more complex things like tf.data (Dataset API, guide), it likely makes a difference. Esp all the examples would be different for graph mode.

Where can I find recent documentation (API references, guides, tutorials, examples) for graph mode? (My current fallback is to check latest TF 1 documentation. But at some point, this will become more and more outdated.)

Or is graph mode deprecated so far that documentation for it seems not necessary anymore?

1 Answers

Graph mode in TensorFlow 2 is different from graph mode in TensorFlow 1. Instead of using sessions and placeholders, TensorFlow 2 uses functions annotated with tf.function. The eager mode examples you see can be executed in graph mode by wrapping them within a tf.function.

If you prefer to use the TensorFlow 1 style of graph mode with sessions and placeholders, you can still do so in TensorFlow 2 by using the tf.compat.v1 module. The API docs in that module describe the TensorFlow 1 style of graph mode. You can find archived guides about TensorFlow 1 graph mode at https://github.com/tensorflow/docs/tree/master/site/en/r1/guide

Related