Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow - Invalid argument: Reshape:0 is both fed and fetched

Is there a way to both feed and fetch the same variable in Tensorflow? If not, why is this not allowed?

I'm getting this error:

StatusNotOK: Invalid argument: Reshape:0 is both fed and fetched.
like image 617
Sam Greydanus Avatar asked May 06 '16 15:05

Sam Greydanus


1 Answers

You can not have a Tensor that is both fed and fetched. The work-around is to add "tf.identity" op and fetch that

tf.reset_default_graph()
a = tf.placeholder(tf.int32)
a_copy = tf.identity(a)
sess = tf.InteractiveSession()
sess.run(a_copy, feed_dict={a:1})
like image 172
Yaroslav Bulatov Avatar answered Oct 18 '22 16:10

Yaroslav Bulatov