Skip to content

Instantly share code, notes, and snippets.

@ResidentMario
Last active January 18, 2019 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ResidentMario/abec5b3b55de48390b9835c8fd145a63 to your computer and use it in GitHub Desktop.
Save ResidentMario/abec5b3b55de48390b9835c8fd145a63 to your computer and use it in GitHub Desktop.
import sagemaker as sage
# this line of code requires iam:GetRole permissions
role = sage.get_execution_role()
# initialize a SageMaker session and use it to get account and region info
# you can also do this using boto3 if you so prefer
# use that to get your home ECR registry, and from there your training image
sess = sage.Session()
account = sess.boto_session.client('sts').get_caller_identity()['Account']
region = sess.boto_session.region_name
image = '{}.dkr.ecr.{}.amazonaws.com/quiltdata/sagemaker-demo'.format(account, region)
# create an estimator and fit it
# replace "s3://quilt-example" in `output_path` with a path into bucket you have access to
clf = sage.estimator.Estimator(image,
role, 1, 'ml.c4.2xlarge',
output_path="s3://quilt-example/quilt/quilt_sagemaker_demo/model",
sagemaker_session=sess)
clf.fit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment