TensorFlow Serving crossed columns strange error

核能气质少年 提交于 2020-01-16 09:13:07

问题


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...?

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"]}]
}

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]

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]]

回答1:


Change "instances" to "inputs" and have another try.



来源:https://stackoverflow.com/questions/57758785/tensorflow-serving-crossed-columns-strange-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!