As you all know there are various ways to initialize your variables in tensorflow. I tried some stuff in combination with a graph definition. See the code below.
def Graph1a():
g1 = tf.Graph()
with g1.as_default() as g:
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul( matrix1, matrix2, name = "product")
sess = tf.Session( graph = g )
sess.run(tf.global_variables_initializer())
return product
def Graph1b():
g1 = tf.Graph()
with g1.as_default() as g:
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul( matrix1, matrix2, name = "product")
sess = tf.Session( graph = g )
sess.run(tf.initialize_all_variables())
return product
def Graph1c():
g1 = tf.Graph()
with g1.as_default() as g:
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul( matrix1, matrix2, name = "product")
with tf.Session( graph = g ) as sess:
tf.global_variables_initializer().run()
return product
Why is it so that Graph1a() and Graph1b() won't return product, while Graph1c() does? I thought these statements were equivalent.