50 lines (33 sloc) 1.67 KB

Eager Execution

Eager execution provides an imperative interface to TensorFlow (similar to NumPy). When you enable eager execution, TensorFlow operations execute immediately; you do not execute a pre-constructed graph with

For example, consider a simple computation in TensorFlow:

x = tf.placeholder(tf.float32, shape=[1, 1])
m = tf.matmul(x, x)

with tf.Session() as sess:
  print(, feed_dict={x: [[2.]]}))

# Will print [[4.]]

Eager execution makes this much simpler:

x = [[2.]]
m = tf.matmul(x, x)



This feature is in early stages and work remains to be done in terms of smooth support for distributed and multi-GPU training and performance.


For eager execution, we recommend using TensorFlow version 1.8 or newer. Installation instructions at


For an introduction to eager execution in TensorFlow, see: