【问题标题】:Identify Required Placeholders in GCMLE Model识别 GCMLE 模型中所需的占位符
【发布时间】:2017-12-06 16:03:42
【问题描述】:

几周前我部署了一个模型,但我忘记了该模型需要哪些输入特征(是的,我知道我应该更好地跟踪这一点)。当我运行以下命令时

gcloud ml-engine predict \
--model $MODEL_NAME \
--version v1 \
--json-instances \
../test.json

我得到以下错误:

{
  "error": "Prediction failed: Exception during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"input size does not match signature\")"
}

我知道我的问题是因为我的 json 请求 (test.json) 中没有包含一些“必需的”占位符,但我无法找出任何方法来追溯找出缺少哪个占位符。

问题与question 相同,当发布者包含丢失的“阈值”张量时,他能够提交预测。

查看给定模型的预期输入的最简单方法是什么?

【问题讨论】:

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


    【解决方案1】:

    服务本身还不允许您查询模型的签名,因此我的建议是尽可能使用saved_model_cli(假设您没有删除原始模型)。比如:

    gcloud ml-engine versions describe v1 --model census | grep deploymentUri
    

    这将输出如下内容:

    deploymentUri: gs://my_bucket/path/to/Servo/1488268526779
    

    现在,使用saved_model_cli

    saved_model_cli show --all --dir gs://my_bucket/path/to/Servo/1488268526779
    

    这将输出如下内容:

    MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
    
    signature_def['serving_default']:
    The given SavedModel SignatureDef contains the following input(s):
    inputs['age'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: Placeholder_8:0
    inputs['capital_gain'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: Placeholder_10:0
    inputs['capital_loss'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: Placeholder_11:0
    inputs['education'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder_2:0
    inputs['education_num'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: Placeholder_9:0
    inputs['gender'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder:0
    inputs['hours_per_week'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1)
        name: Placeholder_12:0
    inputs['marital_status'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder_3:0
    inputs['native_country'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder_7:0
    inputs['occupation'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder_6:0
    inputs['race'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder_1:0
    inputs['relationship'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder_4:0
    inputs['workclass'] tensor_info:
        dtype: DT_STRING
        shape: (-1)
        name: Placeholder_5:0
    The given SavedModel SignatureDef contains the following output(s):
    outputs['classes'] tensor_info:
        dtype: DT_INT64
        shape: (-1)
        name: predictions/classes:0
    outputs['logistic'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 1)
        name: predictions/logistic:0
    outputs['logits'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 1)
        name: add:0
    outputs['probabilities'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1, 2)
        name: predictions/probabilities:0
    Method name is: tensorflow/serving/predict
    

    【讨论】:

    • 是的。我自己才发现这件事。谢谢
    【解决方案2】:

    假设您有与您保存的模型相关联的张量流图。如果您可以打印图表(以文本格式打印 protobuffer)或使用工具进行可视化,您可以在图表中看到“signature_def”字段。这应该告诉您图表的输入和输出。您可以将您在请求中发送的张量与图表预期的输入进行比较。

    【讨论】:

    • 我有相关的 saved_model.pb 文件。我将如何以文本格式打印它?我能够在 tensorboard 中显示模型,但也对打印 protobuf 文件感到好奇
    • 在张量板中显示的图表中也很难找到“signature_def”字段
    猜你喜欢
    • 2020-09-12
    • 2020-12-14
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    相关资源
    最近更新 更多