TensorFlow - 无效参数:重塑:0都是馈送和提取

Sam*_*nus 4 machine-learning tensorflow

有没有办法在Tensorflow中提供和获取相同的变量?如果没有,为什么不允许这样做?

我收到这个错误:

StatusNotOK: Invalid argument: Reshape:0 is both fed and fetched.
Run Code Online (Sandbox Code Playgroud)

Yar*_*tov 7

你不能拥有一个既有馈送也有提取的Tensor.解决方法是添加"tf.identity"op并获取它

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})
Run Code Online (Sandbox Code Playgroud)


Sam*_*nus 0

我刚刚意识到发生错误是因为我运行的是已弃用的 TensorFlow 版本。我仍然有兴趣了解变量如何同时出现在 feed 和 fetch 中!