python - { "error": "inputs is a plain value/list, but expecting an object as multiple input tensors required as per tensorinfo_map" }

标签 python json tensorflow tensorflow-serving

我正在使用 tensorflow 服务来部署我的模型。

我的张量信息图是

saved_model_cli show --dir /export/1/ --tag_set serve --signature_def serving_default

The given SavedModel SignatureDef contains the following input(s):
  inputs['length_0'] tensor_info:
      dtype: DT_INT32
      shape: (-1)
      name: serving_default_length_0:0
  inputs['length_1'] tensor_info:
      dtype: DT_INT32
      shape: (-1)
      name: serving_default_length_1:0
  inputs['length_2'] tensor_info:
      dtype: DT_INT32
      shape: (-1)
      name: serving_default_length_2:0
  inputs['tokens_0'] tensor_info:
      dtype: DT_STRING
      shape: (-1, -1)
      name: serving_default_tokens_0:0
  inputs['tokens_1'] tensor_info:
      dtype: DT_STRING
      shape: (-1, -1)
      name: serving_default_tokens_1:0
  inputs['tokens_2'] tensor_info:
      dtype: DT_STRING
      shape: (-1, -1)
      name: serving_default_tokens_2:0
The given SavedModel SignatureDef contains the following output(s):
  outputs['alignment'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 1, -1, -1)
      name: StatefulPartitionedCall_8:0
  outputs['length'] tensor_info:
      dtype: DT_INT32
      shape: (-1, 1)
      name: StatefulPartitionedCall_8:1
  outputs['log_probs'] tensor_info:
      dtype: DT_FLOAT
      shape: (-1, 1)
      name: StatefulPartitionedCall_8:2
  outputs['tokens'] tensor_info:
      dtype: DT_STRING
      shape: (-1, 1, -1)
      name: StatefulPartitionedCall_8:3
Method name is: tensorflow/serving/predict

我正在发出一个curl请求

curl -X POST -i 'http://192.168.1.16:8501/v1/models/export:predict' --data '{ "signature_name":  "serving_default",  "inputs": [{ "tokens_0" :["text text text text text text text text text text"], "length_0": [1], "tokens_1": ["01 01 01 01 01 01 01 01 01 01"], "length_1": [1], "tokens_2": ["4 4 4 1 1 4 4 4 4 4"], "length_2": [1]}]}'

我想知道我在传递数据时哪里出错了。请求 json 格式应该是什么。

这个特定的模型是一个多特征模型,它接受三个字符串作为输入,然后给出一个字符串作为输出。

最佳答案

您正在以行格式传递输入,因此如果您将“输入”替换为“实例”,一切都会正常工作,See here for the difference between row and columnar format

关于python - { "error": "inputs is a plain value/list, but expecting an object as multiple input tensors required as per tensorinfo_map" },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59878744/

相关文章:

python - 将一个数组作为索引传递给另一个数组?

python - 用其描述或名称替换表情符号

node.js - NodeJS : Loop through nested JSON and remove elements based on a condition

json - Scala 保留字作为 JSON 字段名称与 Json.writes[A]( Play 等效于 @SerializedName)

javascript - 从对 Postgres 表的 JSON 调用中提取数据以用于 Highcharts(无需 PHP)

tensorflow - keras 结合两个损失与可调权重

python - 应用资源时访问多个变量的梯度 [Tensorflow]

python - 检查值是否在元组中的一对值之间?

python - 模块未找到错误 : No module named 'google.appengine'

tensorflow - Tensorflow 对象检测 API 中的过拟合