为 Google AI Platform 推理找到正确的 JSON 格式
Finding the correct JSON format for Google AI Platform inference
我正在尝试 运行 使用 gclouds ai-platform 本地预测命令在 Google 上进行预测 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)
我认为我的输入格式有误,但我找不到正确的格式。有谁知道如何检查保存的模型以找出其正确的输入格式?
您可能需要提供字符串而不是列表。以下输入可能有效:
{"inputs": "Hello World."}
是正确的。您可以通过重复行来批处理多个请求,例如:
{"inputs": "Hello World."}
{"inputs": "Hello Mars."}
我正在尝试 运行 使用 gclouds ai-platform 本地预测命令在 Google 上进行预测 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)
我认为我的输入格式有误,但我找不到正确的格式。有谁知道如何检查保存的模型以找出其正确的输入格式?
您可能需要提供字符串而不是列表。以下输入可能有效:
{"inputs": "Hello World."}
{"inputs": "Hello World."}
{"inputs": "Hello Mars."}