【Tensorflow】报错:Cannot interpret feed_dict key as Tensor: The name 'x' refers to an operation, # > no
2017-06-04 15:12
2006 查看
问题描述:
我尝试给一个tensor输入值的时候报错:
代码如下:
import tensorflow as tf
x = tf.placeholder(tf.float32, (None,), 'x')
y = tf.reduce_sum(x)
sess = tf.Session()
sess.run(y, {x: [1, 2, 3]}
# > 6.0
sess.run(y, {'x': [1, 2, 3]}
# > Cannot interpret feed_dict key as Tensor: The name 'x' refers to an operation,
# > not a Tensor. Tensor names must be of the form "<op_name>:<output_index>".
sess.run(y, {tf.get_default_graph().get_operation_by_name('x').outputs[0]: [1, 2, 3]})
# > 6.0有没有可能feed placeholders以他们的变量名呢?如果不能,为什么?这对随后从磁盘恢复网络后进行feed很有用。
问题解决:
你需要添加 ":0",例如:
print sess.run(y, {'x:0': [1, 2, 3]})
这里是为什么 ":0"要被加上的原因:http://stackoverflow.com/a/37870634/419116
.
我尝试给一个tensor输入值的时候报错:
Cannot interpret feed_dict key as Tensor: The name 'x' refers to an operation, not a Tensor. Tensor names must be of the form "<op_name>:<output_index>".
代码如下:
import tensorflow as tf
x = tf.placeholder(tf.float32, (None,), 'x')
y = tf.reduce_sum(x)
sess = tf.Session()
sess.run(y, {x: [1, 2, 3]}
# > 6.0
sess.run(y, {'x': [1, 2, 3]}
# > Cannot interpret feed_dict key as Tensor: The name 'x' refers to an operation,
# > not a Tensor. Tensor names must be of the form "<op_name>:<output_index>".
sess.run(y, {tf.get_default_graph().get_operation_by_name('x').outputs[0]: [1, 2, 3]})
# > 6.0有没有可能feed placeholders以他们的变量名呢?如果不能,为什么?这对随后从磁盘恢复网络后进行feed很有用。
问题解决:
你需要添加 ":0",例如:
print sess.run(y, {'x:0': [1, 2, 3]})
这里是为什么 ":0"要被加上的原因:http://stackoverflow.com/a/37870634/419116
.
相关文章推荐
- Cannot interpret feed_dict key as Tensor: Can not convert a method into a Tensor.
- Cannot interpret feed_dict key as Tensor: Tensor Tensor("input_x:0", shape=(?, 2), dtype=float32)
- Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation.
- RabbitMQ>Erlang machine stopped instantly (distribution name conflict?). The service is not restarted as OnFail is set to ignore.-报错解决方案 原来是NNND。。。
- The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
- sql server 小技巧(6) Cannot resolve the collation conflict between "Latin1_General_CI_AI" and "Chinese_PRC_CI_AS" in the equal to operation
- An Error occurred While Establishing a Connection Back to the Adminstration Server t3://<servername>
- ros-indigo卸载不全,出现The package <package name> needs to be reinstalled, but I can’t find an archive for
- 严重: WSSERVLET11: failed to parse runtime descriptor: The serviceName cannot be retrieved from an int
- Unable to update the EntitySet 'T_JsAPI' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
- javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter,
- The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact
- AddFieldAsXml cannot be used to set the InternalName correctly
- Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_100_CI_AS" in the equal to operation.
- An association from the table B_USER refers to an unmapped class: com.shxt.framework.book.bo.Dict
- Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: j
- Windows 8在Vmware 8 中安装提示:windows cannot read the<product key> setting from the unattend answer
- An association from the table * refers to an unmapped class: *
- The report server cannot decrypt the symmetric key that is used to access sensitive or encrypted data in a report server databas
- [转]how to sign an assembly with a strong name & how to create a pair key怎样通过强名给程序集签名以及如何创建钥匙对?