Tensorflow Variable
import tensorflow as tf
session = tf.InteractiveSession()
A = tf.Variable(tf.ones([3,3]), name = "A")
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
print(sess.run(A))
[[ 1. 1. 1.]
[ 1. 1. 1.]
[ 1. 1. 1.]]
B = tf.Variable(A.initialized_value()*10, name="B")
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
print(sess.run(B))
[[ 10. 10. 10.]
[ 10. 10. 10.]
[ 10. 10. 10.]]
C = tf.Variable(B.initialized_value() + 2, name="C")
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
print(sess.run(C))
[[ 12. 12. 12.]
[ 12. 12. 12.]
[ 12. 12. 12.]]
%pwd
'/home/cobalt'
Written on February 27, 2017