TensorFlow's eager execution is an imperative programming environment that evaluates operations immediately, without building graphs: operations return concrete values instead of constructing a computational graph to run later.

Eager execution is a flexible machine learning platform for research and experimentation, providing:

  1. An intuitive interface—Structure your code naturally and use Python data structures. Quickly iterate on small models and small data.
  2. Easier debugging—Call ops directly to inspect running models and test changes. Use standard Python debugging tools for immediate error reporting.
  3. Natural control flow—Use Python control flow instead of graph control flow, simplifying the specification of dynamic models.

To use tensorflow with eager execution, you need first upgrade tensorflow to latest version.

pip install --upgrade tensorflow

From Eager user guide:

Eager execution is not included in the latest release (version 1.4) of TensorFlow. To use it, you will need to build TensorFlow from source or install the nightly builds.


In [2]:
import tensorflow as tf

from __future__ import absolute_import, division, print_function

tf.enable_eager_execution()

x = [[2.]]
m = tf.matmul(x, x)
print("hello, {}".format(m))


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-33c6c3c9e931> in <module>()
      6 x = [[2.]]
      7 m = tf.matmul(x, x)
----> 8 tf.enable_eager_execution()
      9 print("hello, {}".format(m))

AttributeError: 'module' object has no attribute 'enable_eager_execution'

In [ ]: