简体   繁体   English

我想知道 Sagemaker 的 model.tar.gz 是否可以用于在另一个笔记本中进行推理?

[英]I wonder if model.tar.gz from Sagemaker can be used for inference in another notebook?

Little background: I successfully ran a regression experiment on AWS and saved the best model from that experiment.小背景:我成功地在 AWS 上进行了回归实验,并从该实验中保存了最佳模型。 I have downloaded my best model as model.tar.gz.我已将我最好的模型下载为model.tar.gz. to use it for inference on my dataset elsewhere.用它来推断我在其他地方的数据集。 I extracted it and uploaded the 'xgboost-model' file into my Jupyter Lab workspace, where my dataset is.我提取了它并将“xgboost-model”文件上传到我的 Jupyter Lab 工作区,我的数据集就在其中。

regression_model = 'xgboost-model'

predictions = regression_model.predict(X_test)

The error I'm getting is:我得到的错误是:

----> 1 predictions = regression_model.predict(X_test)

AttributeError: 'str' object has no attribute 'predict'

I know that XGBRegressor has predict attribute, but my model doesn't seem to have it though it's exported as an xgboost model.我知道XGBRegressor具有predict属性,但我的模型似乎没有它,尽管它被导出为xgboost模型。 Any suggesstions on what I'm supposed to be doing instead?关于我应该做什么的任何建议?

Hey so for your model data, you can use it in another notebook, but you need to make sure the dataset you're predicting on has the same attributes as the data you trained on so that you can predict accurately with the model.嘿,对于您的模型数据,您可以在另一个笔记本中使用它,但您需要确保您预测的数据集与您训练的数据具有相同的属性,以便您可以使用模型进行准确预测。 Second point to try out is using the boto3 invoke_endpoint call, the predict attribute is from the SageMaker Python SDK.尝试的第二点是使用 boto3 invoke_endpoint 调用,predict 属性来自 SageMaker Python SDK。 The boto3 SDK is the general AWS Python SDK. boto3 开发工具包是通用的 AWS Python 开发工具包。 I've attached an example of deploying your endpoint with this model.tar.gz, simply passing in the string is not adequate you need to create an endpoint and then perform inference with either the predict call or the invoke_endpoint call.我附上了一个使用这个 model.tar.gz 部署端点的示例,仅传递字符串是不够的,您需要创建一个端点,然后使用 predict 调用或 invoke_endpoint 调用执行推理。

Example: https://github.com/RamVegiraju/Pre-Trained-Sklearn-SageMaker示例: https ://github.com/RamVegiraju/Pre-Trained-Sklearn-SageMaker

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

相关问题 如何在 SageMaker 中的 model.tar.gz 上创建 model? - How to create a model on model.tar.gz in SageMaker? Python从Sagemaker model.tar.gz获取模型估计器对象(用于预测实例说明) - Python getting model estimator object from Sagemaker model.tar.gz (for prediction instance explanation) 如何从 sagemaker 'model.tar.gz' 文件中使用 scikit 学习模型? - How to use scikit learn model from inside sagemaker 'model.tar.gz' file? 在 AWS Sagemaker 中训练 scikit 学习模型时无法创建 model.tar.gz 文件 - Couldn't create model.tar.gz file while training scikit learn model in AWS Sagemaker 在 AWS Sagemaker 中使用 Tensorflow Estimator 时如何在 S3 中保存 Tensorflow 模型(作为 /output/model.tar.gz) - How to save Tensorflow model in S3 (as /output/model.tar.gz) when using Tensorflow Estimator in AWS Sagemaker Allennlp 训练后不生成 model.tar.gz - Allennlp Does not generate model.tar.gz after training 将保存在 S3 存储桶中的 model 以 tar.gz 格式提取到 sagemaker 笔记本实例 - Extract model saved in S3 bucket as tar.gz format to sagemaker notebook instance gzip tar 文件可以用于 Sagemaker 中的训练数据吗? - Can gzip tar files be used for training data in Sagemaker? 从打包的tar.gz文件中直接加载spacy模型 - Directly load spacy model from packaged tar.gz file SageMaker 推理未找到模型 pkl - Model pkl not found by SageMaker inference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM