我一直在开发一个与云 ML 引擎的在线预测服务一起使用的模型。我的模型包含一个placeholder_with_default
我用它来保存预测显着性阈值的张量。
threshold = tf.placeholder_with_default(0.01, shape=(), name="threshold")
我注意到在使用本地预测时:
gcloud ml-engine local predict --json-instances=data.json --model-dir=/my/model/dir
我不需要提供这个张量的值。例如这是一个有效的输入:
{"features": ["a", "b"], "values": [10, 5]}
然而,当使用在线预测时:
gcloud ml-engine predict --model my_model --version v1 --json-instances data.json
如果我使用上面的 JSON,则会出现错误:
{
"error": "Prediction failed: Exception during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"input size does not match signature\")"
}
但是,如果我包括阈值,那么我就不会。例如:
{"features": ["a", "b"], "values": [10, 5], "threshold": 0.01}
有没有办法让“阈值”成为可选输入?
Thanks
Matthew