python - TensorFlow 占位符错误

标签 python audio machine-learning tensorflow tensorflow-serving

我一直在玩 tensorflow,我已经设法训练模式并提供服务,但是当我尝试运行客户端发送数据进行分类时,我得到了这个错误

grpc.framework.interfaces.face.face.AbortionError: AbortionError(code=StatusCode.INVALID_ARGUMENT, details="You must feed a value for placeholder tensor 'Placeholder_1' with dtype float
[[Node: Placeholder_1 = Placeholder_output_shapes=[[]], dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]]")



我不太明白这个错误,这是我的占位符
X = tf.placeholder(tf.float32,[None,n_dim])
y = tf.placeholder(tf.float32,[None,n_classes])

我在文档中使用了构建器,编写了 prediction_signature 以及分类签名。

如果有人知道为什么会这样,我将不胜感激

最佳答案

您需要实际设置您的值。占位符只是一个占位符,必须使用 feed_dict 设置为实际值。

像这样,请注意 sess.run 行:

import tensorflow as tf

X_vals = 1
X = tf.placeholder(tf.float32)

sess = tf.Session()

# sess.run(X) # This will throw the error you see
sess.run(X, feed_dict={X: X_vals}) # This works

关于python - TensorFlow 占位符错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42939426/

相关文章:

python - 使用 matplotlib.tri.Triangulation 创建在 Matplotlib 的plot_trisurf 中使用的三角剖分

python - pandas 中的自动增量索引

java - 如何通过MediaView播放音频流

java - 循环声音Java

python - 如何启用Dataset pipeline的分布式读取和消费

macos - weka mac安装

machine-learning - 如何使用 numpy 数组从单词映射中检索单词? [Tensorflow RNN] 文本分类

python - 从其查询集中将不同的 CSS 类分配给 Django ModelChoiceField

ios - 如何在 iOS 应用程序中获取蓝牙配置文件状态

Python:最大/最小内置函数取决于参数顺序