用于在Amazon SageMaker上培训和部署模型的开源库。
sagemaker的Python项目详细描述
sagemaker python sdk
><<<<<目录
- 安装sagemaker python sdk
- 使用sagemaker python sdk
- mxnet sagemaker估计器
- tensorflow-sagemaker估计器
- chainer-sagemaker估计器
- pytorch-sagemaker估算器
- scikit-学习sagemaker评估员
- xgboost-sagemaker估计器
- sagemaker强化学习评估器
- Sagemaker SparkML服务
- AWS Sagemaker Estimators
- 使用sagemaker algorithmestimators
- 使用sagemaker模型包
- 带sagemaker估计器的byo docker容器
- sagemaker自动模型调整
- sagemaker批处理转换
- 使用专有网络进行安全培训和推理
- byo model
- 推理管道
- sagemaker工作流 < > >
安装sagemaker python sdk
sagemaker python sdk是根据pypi构建的,可以与pip一起安装,如下所示:
pip install sagemaker
通过克隆此存储库并在存储库的根目录中运行pip install命令,可以从源代码安装:
git clone https://github.com/aws/sagemaker-python-sdk.git cd sagemaker-python-sdk pip install .
支持的操作系统
sagemaker python sdk支持unix/linux和mac。
支持的python版本
sagemaker python sdk测试时间:
- python 2.7版
- python 3.6
AWS权限
作为托管服务,Amazon SageMaker代表您执行由Amazon SageMaker管理的AWS硬件的操作。 amazon sagemaker只能执行用户允许的操作。 您可以在aws文档中阅读有关哪些权限是必需的
除了使用sagemaker所需的权限外,sagemaker python sdk不应要求任何其他权限。 但是,如果使用的是具有路径的iam角色,则应授予对 iam:getrole 的权限。
许可
sagemaker python sdk是在apache 2.0许可下获得许可的。版权所有2018 Amazon.com,Inc.或其附属公司。保留所有权利。许可证可在以下网址获得: http://aws.amazon.com/apache2.0/
运行测试
sagemaker python sdk有单元测试和集成测试。
您可以通过运行
pip install--upgrade.[test]
来安装运行测试所需的库,或者,对于zsh用户:
pip install--upgrade.\[test]
单元测试
我们使用tox运行单元测试,这是一个程序,允许您为多个python版本运行单元测试,并且还确保 代码符合我们的风格指南。我们使用Python2.7和3.6运行tox,以便运行单元测试 使用与我们相同的配置,您需要安装Python2.7和Python3.6的解释器。
要使用tox运行单元测试,请运行:
tox tests/unit
集成测试
要运行集成测试,必须满足以下先决条件
- AWS帐户凭据在BOTO3客户端使用的环境中可用。
-
aws帐户有一个名为
sagemakerrole
的iam角色。 它应该附加amazonsagemakerfullaccess策略,以及具有使用弹性推断所需权限的策略
< > >
我们建议有选择地运行那些您想要运行的集成测试。您可以使用以下命令按单个测试函数名进行筛选:
tox -- -k 'test_i_care_about'
您还可以通过运行以下命令来运行所有集成测试,该命令将按顺序运行这些测试,这可能需要一段时间:
tox -- tests/integ
您也可以并行运行它们:
tox -- -n auto tests/integ
斯芬克斯建筑文档
cd 进入 doc 目录并运行:
make html
您可以通过编辑 doc 目录中的.rst文件,然后再次运行 make html 来编辑文档中任何页面的模板。
MXnet Sagemaker估算值
通过使用mxnet sagemaker估计器,您可以在amazon sagemaker上培训和托管mxnet模型。
支持的MXNET版本: 0.12.1 , 1.0.0 , 1.1.0 , 1.2.1 , 1.3.0 , 1.4.0 , 1.4.1 >
支持的MXNET弹性推理版本: 1.3.0 , 1.4.0 , 1.4.1
我们建议您使用最新的支持版本,因为这是我们大部分开发工作的重点。
有关详细信息,请参见将MXNET与SageMaker Python SDK结合使用
chainer-sagemaker估计量
通过使用chainer sagemaker估计器,您可以在amazon sagemaker上培训和托管chainer模型。
支持的chainer版本: 4.0.0 , 4.1.0 , 5.0.0
我们建议您使用最新的支持版本,因为这是我们大部分开发工作的重点。
有关chainer的更多信息,请参见https://github.com/chainer/chainer rel="nofollow">https://github.com/chainer/chainer
有关chainer sagemaker估计器的更多信息,请参见将chainer与sagemaker python sdk结合使用。
Pythorch Sagemaker估算值
使用pytorch sagemaker估计器,您可以在amazon sagemaker上培训和托管pytorch模型。
支持的pytorch版本: 0.4.0 , 1.0.0 , 1.1.0
我们建议您使用最新的支持版本,因为这是我们大部分开发工作的重点。
有关pytorch的更多信息,请参见https://github.com/pytorch/pytorch" rel="nofollow">https://github.com/pytorch/pytorch
有关pytorch sagemaker估计器的更多信息,请参见//sagemaker.readthedocs.io/en/stable/使用pytorch.html" rel="nofollow">将pytorch与sagemaker python sdk结合使用
scikit学习sagemaker估计器
使用scikit learn sagemaker估计器,您可以在amazon sagemaker上培训和托管scikit learn模型。
支持的scikit learn版本: 0.20.0
我们建议您使用最新的支持版本,因为这是我们大部分开发工作的重点。
有关scikit learn的更多信息,请参见https://scikit-learn.org/stable/" rel="nofollow">https://scikit learn.org/stable/
有关scikit learn sagemaker估计器的更多信息,请参见使用scikit learn和sagemaker python sdk一起使用scikit learn和sagemaker python sdk。
xgboost sagemaker估计量
使用xgboost sagemaker估计器,您可以在amazon sagemaker上培训和托管xgboost模型。
支持的XGBoost版本: 0.90-1
我们建议您使用最新的支持版本,因为这是我们大部分开发工作的重点。
有关xgboost的更多信息,请参见https://xgboost.readthedocs.io/en/latest/" rel="nofollow">https://xgboost.readthedocs.io/en/latest/
有关xgboost sagemaker估计器的更多信息,请参见将xgboost与sagemaker python sdk结合使用。
Sagemaker强化学习估计器
使用强化学习(RL)估计器,您可以使用强化学习在Amazon Sagemaker上训练模型。
coach的支持版本:对于tensorflow, 0.10.1 , 0.11.1 ,对于tensorflow或mxnet, 0.11.0 。 有关coach的更多信息,请参见https://github.com/nervanasystems/coach" rel="nofollow">https://github.com/nervanasystems/coach
支持的Ray版本: 0.5.3 , 0.6.5 ,带有TensorFlow。 有关ray的更多信息,请参见https://github.com/ray-project/ray" rel="nofollow">https://github.com/ray project/ray
有关sagemaker rl估计器的更多信息,请参见sagemaker强化学习估计器。
Sagemaker Sparkml服务
使用sagemaker sparkml服务,您现在可以对sagemaker中的sparkml模型执行预测。 为了在sagemaker中托管sparkml模型,应该使用 mleap 库对其进行序列化。
有关mleap的更多信息,请参见https://github.com/bumble/mleap rel="nofollow">https://github.com/bumble/mleap
支持的Spark主版本:2.2(MLEAP版本-0.9.6)
下面是一个关于如何创建 sparkmodel 类的实例并使用 deploy() 方法创建 可用于对经过训练的SPARKML模型执行预测的端点。
sparkml_model=SparkMLModel(model_data='s3://path/to/model.tar.gz',env={'SAGEMAKER_SPARKML_SCHEMA':schema})model_name='sparkml-model'endpoint_name='sparkml-endpoint'predictor=sparkml_model.deploy(initial_instance_count=1,instance_type='ml.c4.xlarge',endpoint_name=endpoint_name)
一旦部署了模型,我们就可以使用这样的 csv 负载调用端点:
payload='field_1,field_2,field_3,field_4,field_5'predictor.predict(payload)
有关不同 内容类型和 接受格式以及 架构 sagemaker sparkml服务识别,请参见 sagemaker sparkml服务容器
AWS Sagemaker估算值
Amazon Sagemaker提供了几种内置的机器学习算法,您可以使用这些算法来解决各种问题。
算法的完整列表可在以下网址获得: https://docs.aws.amazon.com/sagemaker/latest/dg/algos.html
sagemaker python sdk包括aws k-means的估计器包装、主成分分析(pca)、线性学习器、因子分解机, 潜在dirichlet分配(lda)、神经主题模型(ntm)、随机森林、k近邻(k-nn)、object2vec和ip洞察算法。
有关详细信息,请参见aws sagemaker估计器和模型。