Have a question? Connect with the community at the TensorFlow Forum Visit Forum


Enables / disables eager execution of tf.functions.

Used in the notebooks

Used in the guide

Calling tf.config.run_functions_eagerly(True) will make all invocations of tf.function run eagerly instead of running as a traced graph function.

This can be useful for debugging.

def my_func(a):
 print("Python side effect")
 return a + a
a_fn = tf.function(my_func)
# A side effect the first time the function is traced
Python side effect
<tf.Tensor: shape=(), dtype=int32, numpy=2>
# No further side effect, as the traced function is called
<tf.Tensor: shape=(), dtype=int32, numpy=4>
# Now, switch to eager running
# Side effect, as the function is called directly
Python side effect
<tf.Tensor: shape=(), dtype=int32, numpy=4>
# Turn this back off

run_eagerly Boolean. Whether to run functions eagerly.