【发布时间】:2020-03-27 00:49:57
【问题描述】:
我已经训练了一个 tf 模型(不使用任何 sagemaker 服务)。我使用了 tf 2.1.0 版本。 我用下面的签名def保存了它 MetaGraphDef with tag-set: 'serve' 包含以下 SignatureDef:
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 80)
name: text_input_1:0
The given SavedModel SignatureDef contains the following output(s):
outputs['predictions'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 738)
name: output_1/Identity:0
Method name is: tensorflow/serving/predict
我压缩了模型并使用AWS sagemaker's Python SDK 创建了一个模型对象
model = Model(model_data=s3_location,
role=role,
framework_version='2.1.0')
predictor = model.deploy(initial_instance_count=1, instance_type='ml.m5.xlarge') {code}
模型创建后,我很难预测。我得到了一些奇怪的错误,例如
"error": "Session was not created with a graph before Run()!" 或
"error": "Failed to process element: 0 of 'instances' list. Error: Invalid argument: JSON Value:
我尝试了使用各种格式的 predictor.predict() 方法和 client.invoke_endpoint() 方法,例如 predictor.predict(list)、使用 "instances" 格式的各种 tf 服务 REST API 格式的变体。我也在所有变体上尝试了 json.dumps() 。但没有任何效果。
有人可以建议一种预测方法。如 signature_def 所示,我的输入形状为 (1,80)。
谢谢你
我正在寻找predictor.predict($what here?) 形式的答案。或者建议我在这里做错了什么。
谢谢
【问题讨论】:
标签: tensorflow tensorflow-serving amazon-sagemaker