【问题标题】:Finding the correct JSON format for Google AI Platform inference为 Google AI Platform 推理找到正确的 JSON 格式
【发布时间】:2020-03-20 15:44:05
【问题描述】:

我正在尝试使用 gclouds ai-platform local predict 命令在 Googles Universal Sentence Encoder 上运行预测。我的命令如下所示:

gcloud ai-platform local predict --model-dir=/Users/x/Downloads/universal-sentence-encoder/ --json-instances=instances.json --verbosity debug

instances.json 看起来像这样:

{"inputs": ["Hello World."]}

我从 gcloud 收到以下信息:

cloud.ml.prediction.prediction_utils.PredictionError: Failed to run the provided model: Exception during running the graph: Cannot feed value of shape (1, 1) for Tensor 'serving_default_inputs:0', which has shape '(?,)' (Error code: 2)

我认为我的输入格式有误,但我找不到正确的格式。有谁知道如何检查保存的模型以找出其正确的输入格式?

【问题讨论】:

  • 如果您正在寻找 gcloud 格式:1:cloud.google.com/ml-engine/docs/… 2:cloud.google.com/ml-engine/docs/scikit/… 对于模型,您必须查看他们的通用句子编码器的代码示例。
  • 我已经阅读了该文档,从输入张量的签名中可以看出,它应该是一个字符串数组,所以我不知道为什么这不起作用。
  • 在不使用 gcloud 的情况下您的输入是否有效?
  • 我的输入适用于 TF Hub 模型。

标签: google-cloud-platform gcloud google-cloud-ml


【解决方案1】:

Svetlana's answer 是正确的。您可以通过重复该行来批处理多个请求,例如:

{"inputs": "Hello World."}
{"inputs": "Hello Mars."}

【讨论】:

    【解决方案2】:

    您可能需要提供字符串而不是列表。以下输入可能有效:

    {"inputs": "Hello World."}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-09
      • 1970-01-01
      • 2020-03-13
      • 1970-01-01
      • 2022-06-24
      • 2021-05-10
      • 2020-08-10
      • 1970-01-01
      相关资源
      最近更新 更多