我一直在玩 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/