In [1]:
    
import tensorflow as tf
    
In [2]:
    
print(tf.__version__)
    
    
In [3]:
    
x = tf.Variable(3, name='x')
y = tf.Variable(4, name='4')
z = x*x*y+ y + 2
    
In [4]:
    
sess = tf.Session()
sess.run(x.initializer)
sess.run(y.initializer)
res = sess.run(z)
print(res)
sess.close()
    
    
In [7]:
    
# another way to write the same run code
with tf.Session() as sess:
    x.initializer.run()
    y.initializer.run()
    
    res = z.eval()
    print(res)  #session will close automatically
    
    
In [8]:
    
# instead of running initializer everytime, we can add a initialize node in our computation graph
init = tf.global_variables_initializer()
with tf.Session() as sess:
    init.run()
    print(z.eval())
    
    
In [ ]: