09.05.2023 Views

pdfcoffee

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

TensorFlow 1.x and 2.x

You should see something similar to the following graph:

Figure 1: An example of a computational graph

This section provided an overview of TensorFlow 1.x programming paradigms.

Now, let's turn our attention to what is new in TensorFlow 2.x.

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.

[ 60 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!