Search⌘ K

Flashback: TensorFlow 1

Understand how TensorFlow 1 managed computations using graphs and sessions, requiring explicit graph definitions and session executions. Learn about placeholders, variables, and tensors, and see why TensorFlow 1's design made debugging and modular coding challenging compared to TensorFlow 2's intuitive approach.

We said numerous times that TensorFlow 2 is very different from TensorFlow 1. But we still don’t know what it used to be like. Therefore, let’s now look back to see how the same sigmoid computation could have been implemented in TensorFlow 1.

Warning: We won’t be able to execute the following code in TensorFlow 2.x as it stands.

A graph object

First, we’ll define a graph object, which we’ll populate with operations and variables later:

graph = tf.Graph() # Creates a graph
session = tf.InteractiveSession(graph = graph) # Creates a session

The graph object contains the computational graph that connects the various inputs and outputs we define in our program to get the final desired output. This is the same graph we discussed earlier. Also, we’ll define a session object that takes the defined graph as the input, which executes the graph. ...