# Module: tf.contrib.eager

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/eager/python/tfe.py) |

TensorFlow Eager execution prototype.

EXPERIMENTAL: APIs here are unstable and likely to change without notice.

To use, at program startup, call [`tf.compat.v1.enable_eager_execution()`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/enable_eager_execution).

## Modules

[`metrics`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/metrics) module: Metrics namespace.

## Classes

[`class Checkpoint`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/train/Checkpoint): Groups trackable objects, saving and restoring them.

[`class Checkpointable`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/checkpoint/Checkpointable): Manages dependencies on other objects.

[`class EagerVariableStore`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/EagerVariableStore): Wrapper allowing functional layers to be used with eager execution.

[`class ExecutionCallback`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/ExecutionCallback): Valid callback actions.

[`class GradientTape`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/GradientTape): Record operations for automatic differentiation.

[`class Iterator`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/Iterator): An iterator producing tf.Tensor objects from a tf.data.Dataset.

[`class Network`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/Network): Represents the composition of a set of Layers.

[`class Saver`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/Saver): A tf.compat.v1.train.Saver adapter for use when eager execution is enabled.

[`class Sequential`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/Sequential): Represents a linear sequence of Layers or functions.

[`class TensorSpec`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/TensorSpec): Describes a tf.Tensor.

[`class Variable`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/Variable): Variable based on resource handles.

## Functions

[`add_execution_callback(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/add_execution_callback): Add an execution callback to the default eager context.

[`async_clear_error(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/async_clear_error): Clears errors raised during ASYNC execution mode.

[`async_wait(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/async_wait): Waits for ops dispatched in ASYNC mode to finish.

[`clear_execution_callbacks(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/clear_execution_callbacks): Clear all execution callbacks from the default eager context.

[`connect_to_remote_host(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/config/experimental_connect_to_host): Connects to a single machine to enable remote execution on it.

[`custom_gradient(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/custom_gradient): Decorator to define a function with a custom gradient.

[`defun(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/defun): Compiles a Python function into a callable TensorFlow graph.

[`enable_eager_execution(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/enable_eager_execution): Enables eager execution for the lifetime of this program.

[`enable_remote_eager_execution(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/enable_remote_eager_execution): Enables eager execution for the lifetime of this program.

[`errstate(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/errstate): Context manager setting error state.

[`executing_eagerly(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/executing_eagerly): Returns True if the current thread has eager execution enabled.

[`execution_mode(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/execution_mode): Context manager for setting execution mode for current thread.

[`function(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/function): Creates a callable TensorFlow graph from a Python function.

[`get_optimizer_variables(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/get_optimizer_variables): Returns a list of variables for the given [`tf.compat.v1.train.Optimizer`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/train/Optimizer).

[`gradients_function(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/gradients_function): Returns a function which differentiates f with respect to params.

[`implicit_gradients(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/implicit_gradients): Returns a function which differentiates f with respect to variables.

[`implicit_value_and_gradients(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/implicit_value_and_gradients): Returns a function which differentiates f with respect to variables.

[`in_eager_mode(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/executing_eagerly): Returns True if the current thread has eager execution enabled.

[`inf_callback(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/inf_callback): A specialization of `inf_nan_callback` that checks for `inf`s only.

[`inf_nan_callback(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/inf_nan_callback): An execution callback that checks for `inf`s and `nan`s in output tensors.

[`list_devices(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/config/experimental_list_devices): List the names of the available devices.

[`make_template(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/make_template): Make a template, optionally compiling func_ into a graph function.

[`nan_callback(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/nan_callback): A specialization of `inf_nan_callback` that checks for `nan`s only.

[`num_gpus(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/num_gpus): Get the number of available GPU devices.

[`py_func(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/py_function): Wraps a python function into a TensorFlow op that executes it eagerly.

[`restore_network_checkpoint(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/restore_network_checkpoint): Restore the Network from a checkpoint. (deprecated)

[`restore_variables_on_create(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/restore_variables_on_create): ContextManager that restores variables on creation.

[`run(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/run): Runs the program with an optional main function and argv list.

[`run_all_tests_in_graph_and_eager_modes(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/run_all_tests_in_graph_and_eager_modes): Execute all test methods in the given class with and without eager.

[`run_test_in_graph_and_eager_modes(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/run_test_in_graph_and_eager_modes): Execute the decorated test with and without enabling eager execution.

[`save_network_checkpoint(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/save_network_checkpoint): Save variables from the Network to a checkpoint. (deprecated)

[`set_execution_mode(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/set_execution_mode): Sets execution mode for the current thread.

[`set_server_def(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/set_server_def)

[`seterr(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/seterr): Set how abnormal conditions are handled by the default eager context.

[`value_and_gradients_function(...)`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/contrib/eager/value_and_gradients_function): Returns a function that computes f and its derivative w.r.t. params.

## Other Members

- `ASYNC = 1`
- `DEVICE_PLACEMENT_EXPLICIT = 0`
- `DEVICE_PLACEMENT_SILENT = 2`
- `DEVICE_PLACEMENT_WARN = 1`
- `SYNC = 0`