本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
调用异步终端节点
从异步终端节点托管的模型中获取推论InvokeEndpointAsync.
如果您尚未这样做,请将推理数据(例如机器学习模型、示例数据)上传到 Amazon S3。
在中指定推理数据的位置InputLocation字段和终端节点的名称EndpointName:
# Create a low-level client representing Amazon SageMaker Runtime sagemaker_runtime = boto3.client("sagemaker-runtime", region_name=<aws_region>) # Specify the location of the input. Here, a single SVM sample input_location ="s3://bucket-name/test_point_0.libsvm"# The name of the endpoint. The name must be unique within an AWS Region in your AWS account. endpoint_name='<endpoint-name>'# After you deploy a model into production using SageMaker hosting # services, your client applications use this API to get inferences # from the model hosted at the specified endpoint. response = sagemaker_runtime.invoke_endpoint_async( EndpointName=endpoint_name, InputLocation=input_location)
您会收到一个 JSON 字符串的响应,其中包含请求 ID 和 Amazon S3 存储桶的名称,该存储桶将在处理 API 调用后响应该调用。