The main change in TensorFlow 2 is eager execution. Historically, TensorFlow 1 always used lazy execution by default. It is called lazy because operations are not run by the framework until asked specifically to do so.
Let's start with a very simple example to illustrate the difference between lazy and eager execution, summing the values of two vectors:
import tensorflow as tf
a = tf.constant([1, 2, 3])
b = tf.constant([0, 0, 1])
c = tf.add(a, b)
print(c)
Note that tf.add(a, b) could be replaced by a + b since TensorFlow overloads many Python operators.
The output of the previous code depends on the TensorFlow version. With TensorFlow 1 (where lazy execution is the default mode), the output would be this:
Tensor("Add:0", shape=(3,), dtype=int32)
However, with TensorFlow 2 (where eager execution is the default mode), you would get the following output:
tf.Tensor([1 2 4], shape=(3,), dtype=int32)
In both...