简体   繁体   English

用于批量转换的 AWS SageMaker 部署

[英]AWS SageMaker Deployment for Batch Transform

I am trying to use a XGBoost model in Sage Maker and use it to score for a large data stored in S3 using Batch Transform.我正在尝试在 Sage Maker 中使用 XGBoost 模型,并使用它来使用批量转换对存储在 S3 中的大型数据进行评分。

I build the model using existing Sagemaker Container as follows:我使用现有的 Sagemaker Container 构建模型,如下所示:

estimator = sagemaker.estimator.Estimator(image_name=container, 
                                          hyperparameters=hyperparameters,
                                          role=sagemaker.get_execution_role(),
                                          train_instance_count=1, 
                                          train_instance_type='ml.m5.2xlarge', 
                                          train_volume_size=5, # 5 GB 
                                          output_path=output_path,
                                          train_use_spot_instances=True,
                                          train_max_run=300,
                                          train_max_wait=600)

estimator.fit({'train': s3_input_train,'validation': s3_input_test})

The following code is used to do Batch Transform下面的代码是用来做Batch Transform的

 The location of the test dataset
batch_input = 's3://{}/{}/test/examples'.format(bucket, prefix)

# The location to store the results of the batch transform job
batch_output = 's3://{}/{}/batch-inference'.format(bucket, prefix)

transformer = xgb_model.transformer(instance_count=1, instance_type='ml.m4.xlarge', output_path=batch_output)

transformer.transform(data=batch_input, data_type='S3Prefix', content_type='text/csv', split_type='Line')

transformer.wait()

The above code works fine in Development environment (Jupyter notebook) when the model is built in Jupyter.当模型在 Jupyter 中构建时,上述代码在开发环境(Jupyter notebook)中运行良好。 However, I would like to deploy the model and call its endpoint for Batch Transform.但是,我想部署模型并调用其端点进行批量转换。

Most examples for SageMaker endpoint creation is for scoring on a single data and not for batch transform. SageMaker 端点创建的大多数示例用于对单个数据进行评分,而不是用于批量转换。

Can someone point to how to deploy and use the endpoints for Batch Transform in SageMaker?有人可以指出如何在 SageMaker 中部署和使用批量转换的端点吗? Thank you谢谢

The following link has an example of how to call a stored model in SageMaker to run Batch Transform job.以下链接有一个示例,说明如何在 SageMaker 中调用存储模型来运行批量转换作业。

Batch Transform Reference 批量转换参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM