To fetch the outputs from the graph, we have to execute the run() method, which is inside the Session object. We can pass the ops to the run() method and retrieve the output as tensors:
a = tf.constant(12) b = tf.constant(34) add = tf.add(a,b) sess = tf.Sessions() result = sess.run(add) print(result)
In the preceding code, the value of result will be 12+34.