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

前端 未结 2 1868
一向
一向 2021-01-03 03:24

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: Inval         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 03:44

    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})
    

提交回复
热议问题