0

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.

2

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.