Skip to content

Instantly share code, notes, and snippets.

@sengstacken
Last active April 5, 2021 13:35
Show Gist options
  • Save sengstacken/e2ab7044d143b611d584e683350df3c4 to your computer and use it in GitHub Desktop.
Save sengstacken/e2ab7044d143b611d584e683350df3c4 to your computer and use it in GitHub Desktop.
# get default bucket
bucket_name = sagemaker.Session().default_bucket()
# upload data to s3
# training data for sagemaker
s3_input_train = sagemaker.inputs.TrainingInput(s3_data='s3://{}/{}/data/train'.format(bucket_name, prefix), content_type='csv')
s3_input_validation = sagemaker.inputs.TrainingInput(s3_data='s3://{}/{}/data/val'.format(bucket_name, prefix), content_type='csv')
# generic estimator
xgb = sagemaker.estimator.Estimator(container,
role,
instance_count=1,
instance_type='ml.m4.xlarge',
output_path=f's3://{bucket}/{prefix}/output',
sagemaker_session=sess,
use_spot_instances=True, # Use spot instance
max_run=600, # Max training time
max_wait=3600) # Max training time + spot waiting time
@sengstacken
Copy link
Author

initial commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment