There are ways to initialize tensor with a numpy array. But is there any way to do the opposite. Meaning initialize a numpy array with a tensor in the graph.
1 Answer
You have to evaluate the tensor under a session. Assume you have a tensor t defined as
x = tf.Variable(...)
y = tf.Variable(...)
t = tf.add(x, y)
and you want to know its value (given the current x and y).
You then just use a session to fetch it:
with tf.Session() as sess:
numpy_array = sess.run(t)
or, equivalently,
with tf.Session() as sess:
numpy_array = t.eval(sess)
That should be all there is to it.