# Create session sess = tf.Session() # Initialize variables sess.run(x.initializer) sess.run(y.initializer) # Evaluate result result = sess.run(f) print(result)
with tf.Session() as sess: x.initializer.run() y.initializer.run() result = f.eval() print(result)
''' Tensorflow can also be run in interactive mode, which sets the default global session. ''' sess = tf.InteractiveSession() init.run() result = f.eval() print(result) # Note that you're required to close the session in interactive mode sess.close()