TensorFlow Serving 交叉列奇怪错误 [英] TensorFlow Serving crossed columns strange error
问题描述
当我尝试向我保存的模型发送预测请求时收到以下错误,使用 TensorFlow Serving 运行:
I am receiving the following error when trying to send a prediction request to my saved model, running with TensorFlow Serving:
{
"error": "Expected D2 of index to be 2 got 3 at position 0\n\t [[{{node linear/linear_model/linear_model/linear_model/int2Id_X_stringId/SparseCross}}]]"
}
问题似乎来自尝试在线性模型中使用交叉列......?
The problem appears to come from trying to use crossed columns in a linear model...?
我的服务模型是 tf.estimator.LinearClassifier .我的 REST API 请求是 POST 到model_directory/model:predict",输入如下:
My model in service is a tf.estimator.LinearClassifier . My REST API request is a POST to 'model_directory/model:predict' with the following intput:
{ "signature_name": "predict",
"instances": [{
"intId" : [2],
"int2Id": [847],
"int3Id": [0],
"int4Id":[3],
"stringId" : ["STRING"]}]
}
奇怪的是,在本地使用saved_model_cli和以下命令来获得预测效果非常好:
Strangely, locally using the saved_model_cli with the following command to get a prediction works absolutely fine:
saved_model_cli run --dir Workspace/saves/1567433674 --tag_set serve --signature_def predict --input_exprs int4Id=[3];int1Id=[2];stringId=['STRING'];int3Id=[0];int2Id=[847]
目标是从我提供的模型中获得预测输出,该输出类似于我使用 saved_model_cli 时的输出.像这样:
The goal is to have a prediction output from my served model, an output similar to when I use saved_model_cli. Something like this:
Result for output key all_class_ids:
[[0 1 2 3 4 5]]
Result for output key all_classes:
[[b'0' b'1' b'2' b'3' b'4' b'5']]
Result for output key class_ids:
[[2]]
Result for output key classes:
[[b'2']]
Result for output key logits:
[[ 0.11128154 -0.44881764 0.31520572 -0.08318427 -0.3479367 -0.08883157]]
Result for output key probabilities:
[[0.19719791 0.11263006 0.2418051 0.16234797 0.12458517 0.16143374]]
推荐答案
将实例"更改为输入"并再试一次.
Change "instances" to "inputs" and have another try.
这篇关于TensorFlow Serving 交叉列奇怪错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!