# tf.config.experimental_run_functions_eagerly

<br />

|---|---|
| [![](https://www.tensorflow.org/images/tf_logo_32px.png) TensorFlow 1 version](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/config/experimental_run_functions_eagerly) | [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.1.0/tensorflow/python/eager/def_function.py#L261-L305) |

Enables / disables eager execution of [`tf.function`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/function)s.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.config.experimental_run_functions_eagerly`](https://www.tensorflow.org/api_docs/python/tf/config/experimental_run_functions_eagerly)

<br />

    tf.config.experimental_run_functions_eagerly(
        run_eagerly
    )

Calling [`tf.config.experimental_run_functions_eagerly(True)`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/config/experimental_run_functions_eagerly) will make all
invocations of [`tf.function`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/function) run eagerly instead of running as a traced graph
function.

This can be useful for debugging or profiling. For example, let's say you
implemented a simple iterative sqrt function, and you want to collect the
intermediate values and plot the convergence. Appending the values to a list
in `@tf.function` normally wouldn't work since it will just record the Tensors
being traced, not the values. Instead, you can do the following.

    ys = []

    @tf.function
    def sqrt(x):
      y = x / 2
      d = y
      for _ in range(10):
        d /= 2
        if y * y < x:
          y += d
        else:
          y -= d
        ys.append(y.numpy())
      return y

    tf.config.experimental_run_functions_eagerly(True)
    sqrt(tf.constant(2.))
    <tf.Tensor: shape=(), dtype=float32, numpy=1.4150391>
    ys
    [1.5, 1.25, 1.375, 1.4375, 1.40625, 1.421875, 1.4140625, 1.4179688, 1.4160156,
    1.4150391]
    tf.config.experimental_run_functions_eagerly(False)

Calling [`tf.config.experimental_run_functions_eagerly(False)`](https://www.tensorflow.org/versions/r2.1/api_docs/python/tf/config/experimental_run_functions_eagerly) will undo this
behavior.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `run_eagerly` | Boolean. Whether to run functions eagerly. |

<br />