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.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.config.run_functions_eagerly\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/python/eager/def_function.py#L363-L411) |\n\nEnables / disables eager execution of [`tf.function`](../../tf/function)s.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.config.run_functions_eagerly`](/api_docs/python/tf/config/run_functions_eagerly)\n\n\u003cbr /\u003e\n\n tf.config.run_functions_eagerly(\n run_eagerly\n )\n\nCalling [`tf.config.run_functions_eagerly(True)`](../../tf/config/run_functions_eagerly) will make all\ninvocations of [`tf.function`](../../tf/function) run eagerly instead of running as a traced graph\nfunction.\n\nThis can be useful for debugging or profiling. For example, let's say you\nimplemented a simple iterative sqrt function, and you want to collect the\nintermediate values and plot the convergence. Appending the values to a list\nin `@tf.function` normally wouldn't work since it will just record the Tensors\nbeing traced, not the values. Instead, you can do the following. \n\n ys = []\n\n @tf.function\n def sqrt(x):\n y = x / 2\n d = y\n for _ in range(10):\n d /= 2\n if y * y \u003c x:\n y += d\n else:\n y -= d\n ys.append(y.numpy())\n return y\n\n tf.config.run_functions_eagerly(True)\n sqrt(tf.constant(2.))\n \u003ctf.Tensor: shape=(), dtype=float32, numpy=1.4150391\u003e\n ys\n [1.5, 1.25, 1.375, 1.4375, 1.40625, 1.421875, 1.4140625, 1.4179688, 1.4160156,\n 1.4150391]\n tf.config.run_functions_eagerly(False)\n\nCalling [`tf.config.run_functions_eagerly(False)`](../../tf/config/run_functions_eagerly) will undo this\nbehavior.\n| **Note:** This flag has no effect on functions passed into tf.data transformations as arguments. tf.data functions are never executed eagerly and are always executed as a compiled Tensorflow Graph.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|--------------------------------------------|\n| `run_eagerly` | Boolean. Whether to run functions eagerly. |\n\n\u003cbr /\u003e"]]