python - Tensorflow sess.run InvalidArgumentError:您必须为占位符张量提供一个值
问题描述
我是 TensorFlow 的新手。我x = tf.placeholder(tf.float64, [in_len], name = "x")
在张量模型中有这个占位符。我尝试使用以下注释来执行这个带有输入图像的张量模型img_20_tf
sess = tf.Session()
result_index = sess.run(model.eval(session=sess), feed_dict={x: img_20_tf})
我试图检查 shape 和 dtypeimg_20_tf
并返回我(3072,)
和<dtype: 'float64'>
. 但是,我仍然看到了这个错误:
Traceback (most recent call last):
File "/Users/zhongyuyi/.conda/envs/Packaged program/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call
return fn(*args)
File "/Users/zhongyuyi/.conda/envs/Packaged program/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/Users/zhongyuyi/.conda/envs/Packaged program/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'x' with dtype double and shape [3072]
[[{{node x}}]]
我真的不明白数据类型和形状之间是如何不匹配的。有人可以帮忙吗?非常感谢!
解决方案
推荐阅读
- powershell - 从第 2 行开始的 Powershell 排序
- unity3d - Android 上的 Unity 3d 滑块值重置为最小值
- gcc - 不支持地址清理程序选项“-fsanitize-recover=address”
- javascript - MaterializeCSS轮播设置起始图片无效果
- ios - 展开可选值集合视图时意外发现 nil
- typescript - 如何在 Typescript 中将 stringPropertyInitialization 与 Object.assign 一起使用
- android - Android:创建通知通道的正确位置
- html - 在里面包含一个图标标签
- ios - 在 Swift 中将 12 小时 UTC 日期转换为 24 小时本地时区格式
- three.js - 将 WebGLRenderer 与对数深度缓冲区设置选项设置为 true 与 ShaderMaterial 一起使用