About Lesson
A session will execute the operation from the graph. To execute the graph with the values of a tensor, we need to initialize a session. Within a session, we must run an operator to create an output.
Following we will demonstrate using a TensorFlow Session
import tensorflow as tf ## Create, run and evaluate a session x = tf.constant([2]) y = tf.constant([4]) ## Create operator multiply = tf.multiply(x, y) ## Create a session to run the code sess = tf.Session() result_1 = sess.run(multiply) print(result_1) sess.close()
The output will be [8]