Eager execution in TensorFlow is more Pythonic and allows for rapid prototyping. Unlike the graph mode, where we need to construct a graph every time to perform any operations, eager execution follows the imperative programming paradigm, where any operations can be performed immediately, without having to create a graph, just like we do in Python. Hence, with eager execution, we can say goodbye to sessions and placeholders. It also makes the debugging process easier with an immediate runtime error, unlike the graph mode.
For instance, in the graph mode, to compute anything, we run the session. As shown in the following code, to evaluate the value of z, we have to run the TensorFlow session:
x = tf.constant(11)
y = tf.constant(11)
z = x*y
with tf.Session() as sess:
print sess.run(z)
With eager execution, we don't need to create a session; we can...