Understanding TensorFlow 2.x
As discussed, TensorFlow 2.x recommends using a high-level API such as tf.keras
, but leaves low-level APIs typical of TensorFlow 1.x for when there is a need to have more control on internal details. tf.keras
and TensorFlow 2.x come with some great benefits. Let's review them.
Eager execution
TensorFlow 1.x defines static computational graphs. This type of declarative programming might be confusing for many people. However, Python is typically more dynamic. So, following the Python spirit, PyTorch, another popular deep learning package, defines things in a more imperative and dynamic way: you still have a graph, but you can define, change, and execute nodes on-the-fly, with no special session interfaces or placeholders. This is what is called eager execution, meaning that the model definitions are dynamic, and the execution is immediate. Graphs and sessions should be considered as implementation details.
Both PyTorch and TensorFlow 2 styles...