Returns True if executing eagerly, even if inside a graph function.
This function will check the outermost context for the program and see if it is in eager mode. It is useful comparing to
tf.executing_eagerly(), which checks the current context and will return
False within a
tf.function body. It can be used to build library that behave differently in eager runtime and v1 session runtime (deprecated).
tf.compat.v1.enable_eager_execution() @tf.function def func(): # A function constructs TensorFlow graphs, it does not execute eagerly, # but the outer most context is still eager. assert not tf.executing_eagerly() return tf.compat.v1.executing_eagerly_outside_functions() func() <tf.Tensor: shape=(), dtype=bool, numpy=True>
|boolean, whether the outermost context is in eager mode.|
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.