如何使用pytorch在Sagemaker中创建管道 [英] How to create a pipeline in sagemaker with pytorch
问题描述
我正在用Sagemaker处理文本数据的分类问题.在哪里,我首先将其拟合并转换为结构化格式(例如,通过在sklearn中使用TFIDF),然后将结果保存在S3存储桶中,并将其用于训练我的pytorch模型,并为此在入口点编写了代码.>
如果我们注意到,在上述过程结束时,我有两个模型
- sklearn TFIDF模型
- 实际PyTorch模型
因此,当我每次需要预测新的文本数据时,我都需要使用在培训期间创建的TFIDF模型分别处理(转换)文本数据.
如何使用sklearn的TFIDF和pytorch模型在sagemaker中创建管道.
如果我在入口点的主要方法中使用TFIDF拟合和转换文本数据,则如果在主要方法中训练pytorch模型,则我只能返回将在model_fn()中使用的一个模型
显然,我们需要使用推理管道.
推理管道是一种Amazon SageMaker模型,它由两个到五个容器的线性序列组成,该线性序列处理对数据进行推理的请求.您可以使用推理管道来定义和部署预训练的Amazon SageMaker内置算法与打包在Docker容器中的自定义算法的任意组合.您可以使用推理管道来组合预处理,预测和后处理数据科学任务.推理管道已得到完全管理.
一个人可以在这里阅读文档-
https://docs.aws.amazon.com/sagemaker/latest/dg/inference-pipelines.html
示例-
Apparently, We need to use inference pipelines.
An inference pipeline is an Amazon SageMaker model that is composed of a linear sequence of two to five containers that process requests for inferences on data. You use an inference pipeline to define and deploy any combination of pretrained Amazon SageMaker built-in algorithms and your own custom algorithms packaged in Docker containers. You can use an inference pipeline to combine preprocessing, predictions, and post-processing data science tasks. Inference pipelines are fully managed.
one can read the docs here -
https://docs.aws.amazon.com/sagemaker/latest/dg/inference-pipelines.html
Example -
这篇关于如何使用pytorch在Sagemaker中创建管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!