如何在单次调用时将多个请求发送到AWS Sagemaker Endpoint? [英] How send multiple request to AWS Sagemaker Endpoint on single invoke?

查看:91
本文介绍了如何在单次调用时将多个请求发送到AWS Sagemaker Endpoint?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在SageMaker端点上部署了深度学习模型,并且可以使用 sagemaker_client.invoke_endpoint 请求/获取答案.但是每个 invoke_endpoint 都接受单个主体.如何在一次请求中发送多个正文以获得多个结果?

I've deployed a Deep learning model on SageMaker endpoint and can request/get answer using sagemaker_client.invoke_endpoint. But each invoke_endpoint accepts single body. How can I send multiple body to get multiple result on single request?

我尝试设置 body ='{"instances":[myData1,myData2]}',但是它可以识别为单个字符串.

I've tried setting body='{"instances": [myData1, myData2]}' but It recognizes as single string.

def sagemaker_handler(doc):
    data = doc.encode("UTF-8")
    response = sagemaker_client.invoke_endpoint(EndpointName='myEndpoint',
                                                ContentType='application/json',
                                                Accept='application/json', Body=data)
return response

推荐答案

目前无法使用invoke_endpoint传递多个请求.invoke_endpoint仅在主体中接受一个请求并返回一个预测. https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html

It is not possible to pass multiple requests using the invoke_endpoint at this time. invoke_endpoint only takes one request in the body and returns one prediction. https://docs.aws.amazon.com/sagemaker/latest/dg/API_runtime_InvokeEndpoint.html

SageMaker支持批处理,该批处理可用于多个请求,但这不是通过端点进行的. https://docs.aws.amazon.com/sagemaker/latest/dg/ex1-batch-transform.html

SageMaker supports batch processing which can be used for multiple requests but this is not through an end point though. https://docs.aws.amazon.com/sagemaker/latest/dg/ex1-batch-transform.html

Amazon具有用于传递多个请求和格式的文档,但这仅用于批处理转换. https://docs.aws.amazon.com/sagemaker/Latest/dg/cdf-inference.html

Amazon has documentation for passing multiple requests and formats but this is for batch transformation only. https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html

这篇关于如何在单次调用时将多个请求发送到AWS Sagemaker Endpoint?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆