MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / enable_eager_execution

Function enable_eager_execution

tensorflow/python/framework/ops.py:5731–5799  ·  view source on GitHub ↗

Enables eager execution for the lifetime of this program. Eager execution provides an imperative interface to TensorFlow. With eager execution enabled, TensorFlow functions execute operations immediately (as opposed to adding to a graph to be executed later in a `tf.compat.v1.Session`) and

(config=None, device_policy=None,
                           execution_mode=None)

Source from the content-addressed store, hash-verified

5729
5730@tf_export(v1=["enable_eager_execution"])
5731def enable_eager_execution(config=None, device_policy=None,
5732 execution_mode=None):
5733 """Enables eager execution for the lifetime of this program.
5734
5735 Eager execution provides an imperative interface to TensorFlow. With eager
5736 execution enabled, TensorFlow functions execute operations immediately (as
5737 opposed to adding to a graph to be executed later in a `tf.compat.v1.Session`)
5738 and
5739 return concrete values (as opposed to symbolic references to a node in a
5740 computational graph).
5741
5742 For example:
5743
5744 ```python
5745 tf.compat.v1.enable_eager_execution()
5746
5747 # After eager execution is enabled, operations are executed as they are
5748 # defined and Tensor objects hold concrete values, which can be accessed as
5749 # numpy.ndarray`s through the numpy() method.
5750 assert tf.multiply(6, 7).numpy() == 42
5751 ```
5752
5753 Eager execution cannot be enabled after TensorFlow APIs have been used to
5754 create or execute graphs. It is typically recommended to invoke this function
5755 at program startup and not in a library (as most libraries should be usable
5756 both with and without eager execution).
5757
5758 Args:
5759 config: (Optional.) A `tf.compat.v1.ConfigProto` to use to configure the
5760 environment in which operations are executed. Note that
5761 `tf.compat.v1.ConfigProto` is also used to configure graph execution (via
5762 `tf.compat.v1.Session`) and many options within `tf.compat.v1.ConfigProto`
5763 are not implemented (or are irrelevant) when eager execution is enabled.
5764 device_policy: (Optional.) Policy controlling how operations requiring
5765 inputs on a specific device (e.g., a GPU 0) handle inputs on a different
5766 device (e.g. GPU 1 or CPU). When set to None, an appropriate value will
5767 be picked automatically. The value picked may change between TensorFlow
5768 releases.
5769 Valid values:
5770 - tf.contrib.eager.DEVICE_PLACEMENT_EXPLICIT: raises an error if the
5771 placement is not correct.
5772 - tf.contrib.eager.DEVICE_PLACEMENT_WARN: copies the tensors which are not
5773 on the right device but logs a warning.
5774 - tf.contrib.eager.DEVICE_PLACEMENT_SILENT: silently copies the tensors.
5775 Note that this may hide performance problems as there is no notification
5776 provided when operations are blocked on the tensor being copied between
5777 devices.
5778 - tf.contrib.eager.DEVICE_PLACEMENT_SILENT_FOR_INT32: silently copies
5779 int32 tensors, raising errors on the other ones.
5780 execution_mode: (Optional.) Policy controlling how operations dispatched are
5781 actually executed. When set to None, an appropriate value will be picked
5782 automatically. The value picked may change between TensorFlow releases.
5783 Valid values:
5784 - tf.contrib.eager.SYNC: executes each operation synchronously.
5785 - tf.contrib.eager.ASYNC: executes each operation asynchronously. These
5786 operations may return "non-ready" handles.
5787
5788 Raises:

Callers 1

eager_runFunction · 0.85

Calls 3

setMethod · 0.45
get_cellMethod · 0.45

Tested by

no test coverage detected