我正在尝试通过 github 示例将我自己的病态学习 ML 模型与 SageMaker 一起使用。
python代码如下:
# Define IAM role import boto3
import re
import os
import numpy as np
import pandas as pd
from sagemaker import get_execution_role
import sagemaker as sage from time
import gmtime, strftime
role = get_execution_role()
ess = sage.Session()
account = sess.boto_session.client('sts').get_caller_identity()['Account']
region = sess.boto_session.region_name
image = '{}.dkr.ecr.{}.amazonaws.com/decision-trees-sample:latest'.format(account, region)
output_path="s3://output"
sess
tree = sage.estimator.Estimator(image,
role, 1, 'ml.c4.2xlarge',
output_path='s3-eu-west-1.amazonaws.com/output',
sagemaker_session=sess)
tree.fit("s3://output/iris.csv")
但我得到这个错误:
信息:sagemaker:使用名称创建培训作业:决策树样本-2018-04-24-13-13-38-281
-------------------------------------------------- ------------------------- ClientError Traceback (last last call last) in () 14 sagemaker_session=sess) 15 ---> 16 tree.fit ("s3://inteldatastore-cyrine/iris.csv")
~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/estimator.py in fit(self, inputs, wait, logs, job_name) 161 self.output_path = 's3://{}/' .format(self.sagemaker_session.default_bucket()) 162 --> 163 self.latest_training_job = _TrainingJob.start_new(self, inputs) 164 如果等待:165 self.latest_training_job.wait(logs=logs)
~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/estimator.py in start_new(cls, estimator, inputs) 336 input_config=input_config, role=role, job_name=estimator._current_job_name, 337 output_config= output_config,resource_config=resource_config,--> 338 超参数=hyperparameters,stop_condition=stop_condition)339 340 返回 cls(estimator.sagemaker_session,estimator._current_job_name)
~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/session.py in train(self, image, input_mode, input_config, role, job_name, output_config, resource_config, hyperparameters, stop_condition) 242 LOGGER.info ('使用名称创建训练作业:{}'.format(job_name)) 243 LOGGER.debug('train request: {}'.format(json.dumps(train_request, indent=4))) --> 244 self .sagemaker_client.create_training_job(**train_request) 245 246 def create_model(self, name, role, primary_container):
~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs) 312 "%s() 只接受关键字参数。" % py_operation_name) 313 # 这个范围内的“self”是指BaseClient。--> 314 返回 self._make_api_call(operation_name, kwargs) 315 316 _api_call。名称= str(py_operation_name)
~/anaconda3/envs/python3/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params) 610 error_code = parsed_response.get("错误", {}).get("代码") 611 error_class = self.exceptions.from_code(error_code) --> 612 raise error_class(parsed_response, operation_name) 613 else: 614 return parsed_response
ClientError:调用 CreateTrainingJob 操作时发生错误 (AccessDeniedException):用户:arn:aws:sts::307504647302:assumed-role/default/SageMaker 无权执行:sagemaker:CreateTrainingJob on resource:arn:aws:sagemaker: eu-west-1:307504647302:training-job/decision-trees-sample-2018-04-24-13-13-38-281
你能帮我解决问题吗?
谢谢