Mxnet BYOM: Train locally and deploy on SageMaker.

  1. Introduction

  2. Prerequisites and Preprocessing

    1. Permissions and environment variables

    2. Data Setup

  3. Training the network locally

  4. Set up hosting for the model

    1. Export from MXNet

    2. Import model into SageMaker

    3. Create endpoint

  5. Validate the endpoint for use

Note: Compare this with the tensorflow bring your own model example

Introduction

In this notebook, we will train a neural network locally on the location from where this notebook is run using MXNet. We will then see how to create an endpoint from the trained MXNet model and deploy it on SageMaker. We will then inference from the newly created SageMaker endpoint.

The neural network that we will use is a simple fully-connected neural network. The definition of the neural network can be found in the accompanying mnist.py file. The build_graph method contains the model definition (shown below).

def build_graph():
    data = mx.sym.var('data')
    data = mx.sym.flatten(data=data)
    fc1 = mx.sym.FullyConnected(data=data, num_hidden=128)
    act1 = mx.sym.Activation(data=fc1, act_type="relu")
    fc2 = mx.sym.FullyConnected(data=act1, num_hidden=64)
    act2 = mx.sym.Activation(data=fc2, act_type="relu")
    fc3 = mx.sym.FullyConnected(data=act2, num_hidden=10)
    return mx.sym.SoftmaxOutput(data=fc3, name='softmax')

From this definitnion we can see that there are two fully-connected layers of 128 and 64 neurons each. The activations of the last fully-connected layer is then fed into a Softmax layer of 10 neurons. We use 10 neurons here because the datatset on which we are going to predict is the MNIST dataset of hand-written digit recognition which has 10 classes. More details can be found about the dataset on the creator’s webpage.

Prequisites and Preprocessing

Permissions and environment variables

Here we set up the linkage and authentication to AWS services. In this notebook we only need the roles used to give learning and hosting access to your data. The Sagemaker SDK will use S3 defualt buckets when needed. Supply the role in the variable below.

[1]:
import boto3, re
from sagemaker import get_execution_role

role = get_execution_role()

Data setup

Next, we need to pull the data from the author’s site to our local box. Since we have mxnet utilities, we will use the utilities to download the dataset locally.

[2]:
import mxnet as mx

data = mx.test_utils.get_mnist()

Training

It is time to train the network. Since we are training the network locally, we can make use of mxnet training tools. The training method is also in the accompanying mnist.py file. The method is as follows.

def train(data, hyperparameters= {'learning_rate': 0.11}, num_cpus=1, num_gpus =0 , **kwargs):
    train_labels = data['train_label']
    train_images = data['train_data']
    test_labels = data['test_label']
    test_images = data['test_data']
    batch_size = 100
    train_iter = mx.io.NDArrayIter(train_images, train_labels, batch_size, shuffle=True)
    val_iter = mx.io.NDArrayIter(test_images, test_labels, batch_size)
    logging.getLogger().setLevel(logging.DEBUG)
    mlp_model = mx.mod.Module(
        symbol=build_graph(),
        context=get_train_context(num_cpus, num_gpus))
    mlp_model.fit(train_iter,
                  eval_data=val_iter,
                  optimizer='sgd',
                  optimizer_params={'learning_rate': float(hyperparameters.get("learning_rate", 0.1))},
                  eval_metric='acc',
                  batch_end_callback=mx.callback.Speedometer(batch_size, 100),
                  num_epoch=10)
    return mlp_model

The method above collects the data variable that get_mnist method gives you (which is a dictionary of data arrays) along with a dictionary of hyperparameters which only contains learning rate, and other parameters. It creates a `mxnet.mod.Module <https://mxnet.incubator.apache.org/api/python/module.html>`__ from the network graph we built in the build_graph method and trains the network using the mxnet.mod.Module.fit method.

[3]:
from mnist import train

model = train(data=data, num_cpus=1, num_gpus=0)
INFO:root:Epoch[0] Batch [0-100]        Speed: 88262.86 samples/sec     accuracy=0.110099
INFO:root:Epoch[0] Batch [100-200]      Speed: 87784.23 samples/sec     accuracy=0.116000
INFO:root:Epoch[0] Batch [200-300]      Speed: 87146.04 samples/sec     accuracy=0.111300
INFO:root:Epoch[0] Batch [300-400]      Speed: 87671.20 samples/sec     accuracy=0.111700
INFO:root:Epoch[0] Batch [400-500]      Speed: 86419.02 samples/sec     accuracy=0.157800
INFO:root:Epoch[0] Train-accuracy=0.160133
INFO:root:Epoch[0] Time cost=0.756
INFO:root:Epoch[0] Validation-accuracy=0.495200
INFO:root:Epoch[1] Batch [0-100]        Speed: 87714.28 samples/sec     accuracy=0.592673
INFO:root:Epoch[1] Batch [100-200]      Speed: 86792.59 samples/sec     accuracy=0.756300
INFO:root:Epoch[1] Batch [200-300]      Speed: 87943.81 samples/sec     accuracy=0.803100
INFO:root:Epoch[1] Batch [300-400]      Speed: 87771.55 samples/sec     accuracy=0.819000
INFO:root:Epoch[1] Batch [400-500]      Speed: 88138.78 samples/sec     accuracy=0.842500
INFO:root:Epoch[1] Train-accuracy=0.779067
INFO:root:Epoch[1] Time cost=0.690
INFO:root:Epoch[1] Validation-accuracy=0.866600
INFO:root:Epoch[2] Batch [0-100]        Speed: 86808.40 samples/sec     accuracy=0.875446
INFO:root:Epoch[2] Batch [100-200]      Speed: 86756.51 samples/sec     accuracy=0.888600
INFO:root:Epoch[2] Batch [200-300]      Speed: 86798.70 samples/sec     accuracy=0.903700
INFO:root:Epoch[2] Batch [300-400]      Speed: 87825.03 samples/sec     accuracy=0.908800
INFO:root:Epoch[2] Batch [400-500]      Speed: 87117.62 samples/sec     accuracy=0.919200
INFO:root:Epoch[2] Train-accuracy=0.903433
INFO:root:Epoch[2] Time cost=0.703
INFO:root:Epoch[2] Validation-accuracy=0.926100
INFO:root:Epoch[3] Batch [0-100]        Speed: 87384.97 samples/sec     accuracy=0.928812
INFO:root:Epoch[3] Batch [100-200]      Speed: 87653.42 samples/sec     accuracy=0.933800
INFO:root:Epoch[3] Batch [200-300]      Speed: 86968.78 samples/sec     accuracy=0.933600
INFO:root:Epoch[3] Batch [300-400]      Speed: 87184.62 samples/sec     accuracy=0.935600
INFO:root:Epoch[3] Batch [400-500]      Speed: 87488.51 samples/sec     accuracy=0.938400
INFO:root:Epoch[3] Train-accuracy=0.935700
INFO:root:Epoch[3] Time cost=0.699
INFO:root:Epoch[3] Validation-accuracy=0.946300
INFO:root:Epoch[4] Batch [0-100]        Speed: 87441.63 samples/sec     accuracy=0.944752
INFO:root:Epoch[4] Batch [100-200]      Speed: 87886.13 samples/sec     accuracy=0.949300
INFO:root:Epoch[4] Batch [200-300]      Speed: 87701.99 samples/sec     accuracy=0.950200
INFO:root:Epoch[4] Batch [300-400]      Speed: 87393.90 samples/sec     accuracy=0.953100
INFO:root:Epoch[4] Batch [400-500]      Speed: 88518.99 samples/sec     accuracy=0.956300
INFO:root:Epoch[4] Train-accuracy=0.951350
INFO:root:Epoch[4] Time cost=0.697
INFO:root:Epoch[4] Validation-accuracy=0.956000
INFO:root:Epoch[5] Batch [0-100]        Speed: 86298.82 samples/sec     accuracy=0.960891
INFO:root:Epoch[5] Batch [100-200]      Speed: 88283.67 samples/sec     accuracy=0.961600
INFO:root:Epoch[5] Batch [200-300]      Speed: 87676.14 samples/sec     accuracy=0.959300
INFO:root:Epoch[5] Batch [300-400]      Speed: 87129.20 samples/sec     accuracy=0.963500
INFO:root:Epoch[5] Batch [400-500]      Speed: 87587.35 samples/sec     accuracy=0.959900
INFO:root:Epoch[5] Train-accuracy=0.960917
INFO:root:Epoch[5] Time cost=0.699
INFO:root:Epoch[5] Validation-accuracy=0.960500
INFO:root:Epoch[6] Batch [0-100]        Speed: 87064.82 samples/sec     accuracy=0.967129
INFO:root:Epoch[6] Batch [100-200]      Speed: 86898.32 samples/sec     accuracy=0.965600
INFO:root:Epoch[6] Batch [200-300]      Speed: 88176.39 samples/sec     accuracy=0.966800
INFO:root:Epoch[6] Batch [300-400]      Speed: 87807.75 samples/sec     accuracy=0.964400
INFO:root:Epoch[6] Batch [400-500]      Speed: 77941.77 samples/sec     accuracy=0.968700
INFO:root:Epoch[6] Train-accuracy=0.966550
INFO:root:Epoch[6] Time cost=0.737
INFO:root:Epoch[6] Validation-accuracy=0.965400
INFO:root:Epoch[7] Batch [0-100]        Speed: 72297.89 samples/sec     accuracy=0.972178
INFO:root:Epoch[7] Batch [100-200]      Speed: 77314.36 samples/sec     accuracy=0.971700
INFO:root:Epoch[7] Batch [200-300]      Speed: 75173.88 samples/sec     accuracy=0.971500
INFO:root:Epoch[7] Batch [300-400]      Speed: 80625.89 samples/sec     accuracy=0.970900
INFO:root:Epoch[7] Batch [400-500]      Speed: 87196.95 samples/sec     accuracy=0.972700
INFO:root:Epoch[7] Train-accuracy=0.972367
INFO:root:Epoch[7] Time cost=0.768
INFO:root:Epoch[7] Validation-accuracy=0.968200
INFO:root:Epoch[8] Batch [0-100]        Speed: 87498.73 samples/sec     accuracy=0.978218
INFO:root:Epoch[8] Batch [100-200]      Speed: 86962.10 samples/sec     accuracy=0.973700
INFO:root:Epoch[8] Batch [200-300]      Speed: 86726.19 samples/sec     accuracy=0.975200
INFO:root:Epoch[8] Batch [300-400]      Speed: 86964.99 samples/sec     accuracy=0.975900
INFO:root:Epoch[8] Batch [400-500]      Speed: 87148.21 samples/sec     accuracy=0.974500
INFO:root:Epoch[8] Train-accuracy=0.975467
INFO:root:Epoch[8] Time cost=0.703
INFO:root:Epoch[8] Validation-accuracy=0.964300
INFO:root:Epoch[9] Batch [0-100]        Speed: 88023.91 samples/sec     accuracy=0.980297
INFO:root:Epoch[9] Batch [100-200]      Speed: 85248.00 samples/sec     accuracy=0.973700
INFO:root:Epoch[9] Batch [200-300]      Speed: 87012.98 samples/sec     accuracy=0.979700
INFO:root:Epoch[9] Batch [300-400]      Speed: 87292.04 samples/sec     accuracy=0.976200
INFO:root:Epoch[9] Batch [400-500]      Speed: 87294.58 samples/sec     accuracy=0.979600
INFO:root:Epoch[9] Train-accuracy=0.978000
INFO:root:Epoch[9] Time cost=0.702
INFO:root:Epoch[9] Validation-accuracy=0.968400

Set up hosting for the model

Export the model from mxnet

In order to set up hosting, we have to import the model from training to hosting. We will begin by exporting the model from MXNet and saving it down. Analogous to the TensorFlow example, some structure needs to be followed. The exported model has to be converted into a form that is readable by sagemaker.mxnet.model.MXNetModel. The following code describes exporting the model in a form that does the same:

[4]:
import os
import json
import tarfile

os.mkdir("model")

model.save_checkpoint("model/model", 0000)
with open("model/model-shapes.json", "w") as shapes:
    json.dump([{"shape": model.data_shapes[0][1], "name": "data"}], shapes)

def flatten(tarinfo):
    tarinfo.name = os.path.basename(tarinfo.name)
    return tarinfo


tar = tarfile.open("model.tar.gz", "w:gz")
tar.add("model", filter=flatten)
tar.close()
INFO:root:Saved checkpoint to "model/model-0000.params"

The above piece of code essentially hacks the MXNet model export into a sagemaker-readable model export. Study the exported model files if you want to organize your exports in the same fashion as well. Alternatively, you can load the model on MXNet itself and load the sagemaker model as you normally would. Refer here for details on how to load MXNet models.

Import model into SageMaker

Open a new sagemaker session and upload the model on to the default S3 bucket. We can use the sagemaker.Session.upload_data method to do this. We need the location of where we exported the model from MXNet and where in our default bucket we want to store the model(/model). The default S3 bucket can be found using the sagemaker.Session.default_bucket method.

[6]:
import sagemaker

sagemaker_session = sagemaker.Session()
inputs = sagemaker_session.upload_data(path="model.tar.gz", key_prefix="model")
DEBUG:botocore.hooks:Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
DEBUG:botocore.hooks:Changing event name from before-call.apigateway to before-call.api-gateway
DEBUG:botocore.hooks:Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
DEBUG:botocore.hooks:Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
DEBUG:botocore.hooks:Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
DEBUG:botocore.hooks:Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
DEBUG:botocore.hooks:Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
DEBUG:botocore.hooks:Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
DEBUG:botocore.hooks:Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
DEBUG:botocore.utils:IMDS ENDPOINT: http://169.254.169.254/
DEBUG:botocore.credentials:Looking for credentials via: env
DEBUG:botocore.credentials:Looking for credentials via: assume-role
DEBUG:botocore.credentials:Looking for credentials via: assume-role-with-web-identity
DEBUG:botocore.credentials:Looking for credentials via: sso
DEBUG:botocore.credentials:Looking for credentials via: shared-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: custom-process
DEBUG:botocore.credentials:Looking for credentials via: config-file
DEBUG:botocore.credentials:Looking for credentials via: ec2-credentials-file
DEBUG:botocore.credentials:Looking for credentials via: boto-config
DEBUG:botocore.credentials:Looking for credentials via: container-role
DEBUG:botocore.credentials:Looking for credentials via: iam-role
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 169.254.169.254:80
DEBUG:urllib3.connectionpool:http://169.254.169.254:80 "PUT /latest/api/token HTTP/1.1" 200 56
DEBUG:urllib3.connectionpool:Resetting dropped connection: 169.254.169.254
DEBUG:urllib3.connectionpool:http://169.254.169.254:80 "GET /latest/meta-data/iam/security-credentials/ HTTP/1.1" 200 29
DEBUG:urllib3.connectionpool:Resetting dropped connection: 169.254.169.254
DEBUG:urllib3.connectionpool:http://169.254.169.254:80 "GET /latest/meta-data/iam/security-credentials/hongshan-sagemaker-experiment HTTP/1.1" 200 1298
DEBUG:botocore.credentials:Found credentials from IAM Role: hongshan-sagemaker-experiment
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/data/endpoints.json
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f2945acc9d8>
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/data/sagemaker/2017-07-24/service-2.json
DEBUG:botocore.hooks:Event creating-client-class.sagemaker: calling handler <function add_generate_presigned_url at 0x7f2945b80510>
DEBUG:botocore.endpoint:Setting api.sagemaker timeout as (60, 60)
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/data/_retry.json
DEBUG:botocore.client:Registering retry handlers for service: sagemaker
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f2945acc9d8>
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/data/sagemaker-runtime/2017-05-13/service-2.json
DEBUG:botocore.hooks:Event creating-client-class.sagemaker-runtime: calling handler <function add_generate_presigned_url at 0x7f2945b80510>
DEBUG:botocore.endpoint:Setting runtime.sagemaker timeout as (60, 80)
DEBUG:botocore.client:Registering retry handlers for service: sagemaker-runtime
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/data/endpoints.json
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f2945acc9d8>
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/data/sts/2011-06-15/service-2.json
DEBUG:botocore.hooks:Event creating-client-class.sts: calling handler <function add_generate_presigned_url at 0x7f2945b80510>
DEBUG:botocore.endpoint:Setting sts timeout as (60, 60)
DEBUG:botocore.client:Registering retry handlers for service: sts
DEBUG:botocore.hooks:Event before-parameter-build.sts.GetCallerIdentity: calling handler <function generate_idempotent_uuid at 0x7f2945aecd90>
DEBUG:botocore.hooks:Event before-call.sts.GetCallerIdentity: calling handler <function inject_api_version_header_if_needed at 0x7f2945af0598>
DEBUG:botocore.endpoint:Making request for OperationModel(name=GetCallerIdentity) with params: {'url_path': '/', 'query_string': '', 'method': 'POST', 'headers': {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': 'Boto3/1.16.36 Python/3.6.10 Linux/4.15.0-1065-aws Botocore/1.19.9'}, 'body': {'Action': 'GetCallerIdentity', 'Version': '2011-06-15'}, 'url': 'https://sts.us-west-2.amazonaws.com/', 'context': {'client_region': 'us-west-2', 'client_config': <botocore.config.Config object at 0x7f28e10d3240>, 'has_streaming_input': False, 'auth_type': None}}
DEBUG:botocore.hooks:Event request-created.sts.GetCallerIdentity: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f28e10d3208>>
DEBUG:botocore.hooks:Event choose-signer.sts.GetCallerIdentity: calling handler <function set_operation_specific_signer at 0x7f2945aecc80>
DEBUG:botocore.auth:Calculating signature using v4 auth.
DEBUG:botocore.auth:CanonicalRequest:
POST
/

content-type:application/x-www-form-urlencoded; charset=utf-8
host:sts.us-west-2.amazonaws.com
x-amz-date:20210604T181419Z
x-amz-security-token:IQoJb3JpZ2luX2VjEGIaCXVzLXdlc3QtMiJHMEUCIEOfqGya0Mn6jr1RVpzCFv+7vrC9K7EsGTA4IRda73esAiEA2VK1eLYhomSbeYMrIVDpIafH2ec3IvlMf5gTJRLxeoIq+gMIGxADGgw2ODg1MjA0NzEzMTYiDEtvG1DeRLaCoX6xpSrXA2N8QmbkLOBVAwgfv8v3tAih8PWY3tZI7McnzZ1VNy2KTcp2gqchjElFIxq4VOH1QSbIRd8WG7iCr8DcZCC27RZo6SIC5ip12vJorLf3vgkhhqeQXIdpEDSjdDHyrOuLESI1J/ZPrn5Aor8NeMqEoB1kDAFT795swBulfVkpFSSjtRehAEkoZxOovwHsOiM/INY8Kj0fdH0cpQ+hSVetTwEedelGLyd03n400y4ewekmCdcAnp4HaPurSLet3ewDL30KmZGwqx3gpz8eR5CiZR+V+symk05SlTnX797VvAPfGWs+eHyfAqpMfKnG+XD9xjQxnfo0AahGdQ2Uvnvxz4Oe0Cwtx3yrHXyL/dPk6taaIZp07zvrMnEYwxG7k6QcA70x9nGZ3GMEpg9u7HWMB63NBv2OQfyLP9U+cqTjPoljR/Q9TaABBBn6YYqLqA7yDcJJ13ZhrqL/u9T0ag3rkaG3iOSGJWE+IrzXXmhI5JnJFxi/a+9wRLtu1Q66VES8t8j0b17aItOOKP4tVshyQ8CGTgkYjilSxWOzEYIJlz1c0NEOzy9/dVVqsjXgvG2kX2USqSnmIDmNgzRO4DAKuOnJYIM6PevT78I96OPE8Zv0peBzggJ9VzDH0emFBjqlAZuaNAdTVF7vs3OcAV+mbX/qa9vaL61mY+d2Tu+ZzlvXm/e4fow8nQsym0ITCa/xIwjpecfOWRoD/DTIQWpMZZVQZXK3omBIBkNz0tyhCdJUDgg5MFku9eagwvSsl2GjHPb0pW0gXVdhUpeTsz2k+gkZC242DF1FkoZOtqdBf9QZyG315WEUssMqjYAQhj867bF5RazMCE/wZ2uEnN2gKgL/DkqtLA==

content-type;host;x-amz-date;x-amz-security-token
ab821ae955788b0e33ebd34c208442ccfc2d406e2edc5e7a39bd6458fbb4f843
DEBUG:botocore.auth:StringToSign:
AWS4-HMAC-SHA256
20210604T181419Z
20210604/us-west-2/sts/aws4_request
dc940c27bf90dbb22b98620d80ead920757eca7af33c47bcb219c7c0b97d1867
DEBUG:botocore.auth:Signature:
5c06885444ddd8bf6c6658728f68f55485bc86120848b8741dca5da2d96e5eb9
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=POST, url=https://sts.us-west-2.amazonaws.com/, headers={'Content-Type': b'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent': b'Boto3/1.16.36 Python/3.6.10 Linux/4.15.0-1065-aws Botocore/1.19.9', 'X-Amz-Date': b'20210604T181419Z', 'X-Amz-Security-Token': b'IQoJb3JpZ2luX2VjEGIaCXVzLXdlc3QtMiJHMEUCIEOfqGya0Mn6jr1RVpzCFv+7vrC9K7EsGTA4IRda73esAiEA2VK1eLYhomSbeYMrIVDpIafH2ec3IvlMf5gTJRLxeoIq+gMIGxADGgw2ODg1MjA0NzEzMTYiDEtvG1DeRLaCoX6xpSrXA2N8QmbkLOBVAwgfv8v3tAih8PWY3tZI7McnzZ1VNy2KTcp2gqchjElFIxq4VOH1QSbIRd8WG7iCr8DcZCC27RZo6SIC5ip12vJorLf3vgkhhqeQXIdpEDSjdDHyrOuLESI1J/ZPrn5Aor8NeMqEoB1kDAFT795swBulfVkpFSSjtRehAEkoZxOovwHsOiM/INY8Kj0fdH0cpQ+hSVetTwEedelGLyd03n400y4ewekmCdcAnp4HaPurSLet3ewDL30KmZGwqx3gpz8eR5CiZR+V+symk05SlTnX797VvAPfGWs+eHyfAqpMfKnG+XD9xjQxnfo0AahGdQ2Uvnvxz4Oe0Cwtx3yrHXyL/dPk6taaIZp07zvrMnEYwxG7k6QcA70x9nGZ3GMEpg9u7HWMB63NBv2OQfyLP9U+cqTjPoljR/Q9TaABBBn6YYqLqA7yDcJJ13ZhrqL/u9T0ag3rkaG3iOSGJWE+IrzXXmhI5JnJFxi/a+9wRLtu1Q66VES8t8j0b17aItOOKP4tVshyQ8CGTgkYjilSxWOzEYIJlz1c0NEOzy9/dVVqsjXgvG2kX2USqSnmIDmNgzRO4DAKuOnJYIM6PevT78I96OPE8Zv0peBzggJ9VzDH0emFBjqlAZuaNAdTVF7vs3OcAV+mbX/qa9vaL61mY+d2Tu+ZzlvXm/e4fow8nQsym0ITCa/xIwjpecfOWRoD/DTIQWpMZZVQZXK3omBIBkNz0tyhCdJUDgg5MFku9eagwvSsl2GjHPb0pW0gXVdhUpeTsz2k+gkZC242DF1FkoZOtqdBf9QZyG315WEUssMqjYAQhj867bF5RazMCE/wZ2uEnN2gKgL/DkqtLA==', 'Authorization': b'AWS4-HMAC-SHA256 Credential=ASIA2ATYEUMKLLIXRTUU/20210604/us-west-2/sts/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-security-token, Signature=5c06885444ddd8bf6c6658728f68f55485bc86120848b8741dca5da2d96e5eb9', 'Content-Length': '43'}>
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): sts.us-west-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://sts.us-west-2.amazonaws.com:443 "POST / HTTP/1.1" 200 474
DEBUG:botocore.parsers:Response headers: {'x-amzn-RequestId': '4cb62a40-05ed-4ff0-acb0-a525a9cec11c', 'Content-Type': 'text/xml', 'Content-Length': '474', 'Date': 'Fri, 04 Jun 2021 18:14:19 GMT'}
DEBUG:botocore.parsers:Response body:
b'<GetCallerIdentityResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">\n  <GetCallerIdentityResult>\n    <Arn>arn:aws:sts::688520471316:assumed-role/hongshan-sagemaker-experiment/i-01b049c9062e751b4</Arn>\n    <UserId>AROA2ATYEUMKDEDDIH6VZ:i-01b049c9062e751b4</UserId>\n    <Account>688520471316</Account>\n  </GetCallerIdentityResult>\n  <ResponseMetadata>\n    <RequestId>4cb62a40-05ed-4ff0-acb0-a525a9cec11c</RequestId>\n  </ResponseMetadata>\n</GetCallerIdentityResponse>\n'
DEBUG:botocore.hooks:Event needs-retry.sts.GetCallerIdentity: calling handler <botocore.retryhandler.RetryHandler object at 0x7f28e10d3550>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/.local/lib/python3.6/site-packages/boto3/data/s3/2006-03-01/resources-1.json
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f2945acc9d8>
DEBUG:botocore.loaders:Loading JSON file: /home/ubuntu/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/botocore/data/s3/2006-03-01/service-2.json
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function add_generate_presigned_post at 0x7f2945b80730>
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function lazy_call.<locals>._handler at 0x7f29297a36a8>
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function add_generate_presigned_url at 0x7f2945b80510>
DEBUG:botocore.endpoint:Setting s3 timeout as (60, 60)
DEBUG:botocore.client:Registering retry handlers for service: s3
DEBUG:boto3.resources.factory:Loading s3:s3
DEBUG:boto3.resources.factory:Loading s3:Bucket
DEBUG:boto3.resources.model:Renaming Bucket attribute name
DEBUG:botocore.hooks:Event creating-resource-class.s3.Bucket: calling handler <function lazy_call.<locals>._handler at 0x7f28ecc2df28>
DEBUG:botocore.hooks:Event before-parameter-build.s3.ListBuckets: calling handler <function validate_bucket_name at 0x7f2945aecf28>
DEBUG:botocore.hooks:Event before-parameter-build.s3.ListBuckets: calling handler <bound method S3RegionRedirector.redirect_from_cache of <botocore.utils.S3RegionRedirector object at 0x7f28e100ae48>>
DEBUG:botocore.hooks:Event before-parameter-build.s3.ListBuckets: calling handler <bound method S3ArnParamHandler.handle_arn of <botocore.utils.S3ArnParamHandler object at 0x7f28e0fcc278>>
DEBUG:botocore.hooks:Event before-parameter-build.s3.ListBuckets: calling handler <function generate_idempotent_uuid at 0x7f2945aecd90>
DEBUG:botocore.hooks:Event before-call.s3.ListBuckets: calling handler <function add_expect_header at 0x7f2945af22f0>
DEBUG:botocore.hooks:Event before-call.s3.ListBuckets: calling handler <bound method S3RegionRedirector.set_request_url of <botocore.utils.S3RegionRedirector object at 0x7f28e100ae48>>
DEBUG:botocore.hooks:Event before-call.s3.ListBuckets: calling handler <function inject_api_version_header_if_needed at 0x7f2945af0598>
DEBUG:botocore.endpoint:Making request for OperationModel(name=ListBuckets) with params: {'url_path': '/', 'query_string': '', 'method': 'GET', 'headers': {'User-Agent': 'Boto3/1.16.36 Python/3.6.10 Linux/4.15.0-1065-aws Botocore/1.19.9 Resource'}, 'body': b'', 'url': 'https://s3.us-west-2.amazonaws.com/', 'context': {'client_region': 'us-west-2', 'client_config': <botocore.config.Config object at 0x7f28e1198c50>, 'has_streaming_input': False, 'auth_type': None, 'signing': {'bucket': None}}}
DEBUG:botocore.hooks:Event request-created.s3.ListBuckets: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f28e1198c18>>
DEBUG:botocore.hooks:Event choose-signer.s3.ListBuckets: calling handler <bound method ClientCreator._default_s3_presign_to_sigv2 of <botocore.client.ClientCreator object at 0x7f28e10d3240>>
DEBUG:botocore.hooks:Event choose-signer.s3.ListBuckets: calling handler <function set_operation_specific_signer at 0x7f2945aecc80>
DEBUG:botocore.hooks:Event before-sign.s3.ListBuckets: calling handler <bound method S3EndpointSetter.set_endpoint of <botocore.utils.S3EndpointSetter object at 0x7f28e0fcc2e8>>
DEBUG:botocore.utils:Defaulting to S3 virtual host style addressing with path style addressing fallback.
DEBUG:botocore.auth:Calculating signature using v4 auth.
DEBUG:botocore.auth:CanonicalRequest:
GET
/

host:s3.us-west-2.amazonaws.com
x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-date:20210604T181419Z
x-amz-security-token:IQoJb3JpZ2luX2VjEGIaCXVzLXdlc3QtMiJHMEUCIEOfqGya0Mn6jr1RVpzCFv+7vrC9K7EsGTA4IRda73esAiEA2VK1eLYhomSbeYMrIVDpIafH2ec3IvlMf5gTJRLxeoIq+gMIGxADGgw2ODg1MjA0NzEzMTYiDEtvG1DeRLaCoX6xpSrXA2N8QmbkLOBVAwgfv8v3tAih8PWY3tZI7McnzZ1VNy2KTcp2gqchjElFIxq4VOH1QSbIRd8WG7iCr8DcZCC27RZo6SIC5ip12vJorLf3vgkhhqeQXIdpEDSjdDHyrOuLESI1J/ZPrn5Aor8NeMqEoB1kDAFT795swBulfVkpFSSjtRehAEkoZxOovwHsOiM/INY8Kj0fdH0cpQ+hSVetTwEedelGLyd03n400y4ewekmCdcAnp4HaPurSLet3ewDL30KmZGwqx3gpz8eR5CiZR+V+symk05SlTnX797VvAPfGWs+eHyfAqpMfKnG+XD9xjQxnfo0AahGdQ2Uvnvxz4Oe0Cwtx3yrHXyL/dPk6taaIZp07zvrMnEYwxG7k6QcA70x9nGZ3GMEpg9u7HWMB63NBv2OQfyLP9U+cqTjPoljR/Q9TaABBBn6YYqLqA7yDcJJ13ZhrqL/u9T0ag3rkaG3iOSGJWE+IrzXXmhI5JnJFxi/a+9wRLtu1Q66VES8t8j0b17aItOOKP4tVshyQ8CGTgkYjilSxWOzEYIJlz1c0NEOzy9/dVVqsjXgvG2kX2USqSnmIDmNgzRO4DAKuOnJYIM6PevT78I96OPE8Zv0peBzggJ9VzDH0emFBjqlAZuaNAdTVF7vs3OcAV+mbX/qa9vaL61mY+d2Tu+ZzlvXm/e4fow8nQsym0ITCa/xIwjpecfOWRoD/DTIQWpMZZVQZXK3omBIBkNz0tyhCdJUDgg5MFku9eagwvSsl2GjHPb0pW0gXVdhUpeTsz2k+gkZC242DF1FkoZOtqdBf9QZyG315WEUssMqjYAQhj867bF5RazMCE/wZ2uEnN2gKgL/DkqtLA==

host;x-amz-content-sha256;x-amz-date;x-amz-security-token
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
DEBUG:botocore.auth:StringToSign:
AWS4-HMAC-SHA256
20210604T181419Z
20210604/us-west-2/s3/aws4_request
1ba4c40ed14ddda9a226d19127e7d1f714193704f036b36a2728d4930ce45257
DEBUG:botocore.auth:Signature:
fbca8d350908217d844d9f6308f7037e96c1bacada6de8378c4b23d0a1e31a1d
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=GET, url=https://s3.us-west-2.amazonaws.com/, headers={'User-Agent': b'Boto3/1.16.36 Python/3.6.10 Linux/4.15.0-1065-aws Botocore/1.19.9 Resource', 'X-Amz-Date': b'20210604T181419Z', 'X-Amz-Security-Token': b'IQoJb3JpZ2luX2VjEGIaCXVzLXdlc3QtMiJHMEUCIEOfqGya0Mn6jr1RVpzCFv+7vrC9K7EsGTA4IRda73esAiEA2VK1eLYhomSbeYMrIVDpIafH2ec3IvlMf5gTJRLxeoIq+gMIGxADGgw2ODg1MjA0NzEzMTYiDEtvG1DeRLaCoX6xpSrXA2N8QmbkLOBVAwgfv8v3tAih8PWY3tZI7McnzZ1VNy2KTcp2gqchjElFIxq4VOH1QSbIRd8WG7iCr8DcZCC27RZo6SIC5ip12vJorLf3vgkhhqeQXIdpEDSjdDHyrOuLESI1J/ZPrn5Aor8NeMqEoB1kDAFT795swBulfVkpFSSjtRehAEkoZxOovwHsOiM/INY8Kj0fdH0cpQ+hSVetTwEedelGLyd03n400y4ewekmCdcAnp4HaPurSLet3ewDL30KmZGwqx3gpz8eR5CiZR+V+symk05SlTnX797VvAPfGWs+eHyfAqpMfKnG+XD9xjQxnfo0AahGdQ2Uvnvxz4Oe0Cwtx3yrHXyL/dPk6taaIZp07zvrMnEYwxG7k6QcA70x9nGZ3GMEpg9u7HWMB63NBv2OQfyLP9U+cqTjPoljR/Q9TaABBBn6YYqLqA7yDcJJ13ZhrqL/u9T0ag3rkaG3iOSGJWE+IrzXXmhI5JnJFxi/a+9wRLtu1Q66VES8t8j0b17aItOOKP4tVshyQ8CGTgkYjilSxWOzEYIJlz1c0NEOzy9/dVVqsjXgvG2kX2USqSnmIDmNgzRO4DAKuOnJYIM6PevT78I96OPE8Zv0peBzggJ9VzDH0emFBjqlAZuaNAdTVF7vs3OcAV+mbX/qa9vaL61mY+d2Tu+ZzlvXm/e4fow8nQsym0ITCa/xIwjpecfOWRoD/DTIQWpMZZVQZXK3omBIBkNz0tyhCdJUDgg5MFku9eagwvSsl2GjHPb0pW0gXVdhUpeTsz2k+gkZC242DF1FkoZOtqdBf9QZyG315WEUssMqjYAQhj867bF5RazMCE/wZ2uEnN2gKgL/DkqtLA==', 'X-Amz-Content-SHA256': b'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': b'AWS4-HMAC-SHA256 Credential=ASIA2ATYEUMKLLIXRTUU/20210604/us-west-2/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=fbca8d350908217d844d9f6308f7037e96c1bacada6de8378c4b23d0a1e31a1d'}>
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): s3.us-west-2.amazonaws.com:443
DEBUG:urllib3.connectionpool:https://s3.us-west-2.amazonaws.com:443 "GET / HTTP/1.1" 200 None
DEBUG:botocore.parsers:Response headers: {'x-amz-id-2': 'I+MYPGoQXa+gUqC8g6mE39XVM/QxyG5IpbBF1sjD2cvjmoc07lmmQ/6PKtIbo+b75g1nIruRqqA=', 'x-amz-request-id': 'TB9DS18TDXS76DAT', 'Date': 'Fri, 04 Jun 2021 18:14:20 GMT', 'Content-Type': 'application/xml', 'Transfer-Encoding': 'chunked', 'Server': 'AmazonS3'}
DEBUG:botocore.parsers:Response body:
b'<?xml version="1.0" encoding="UTF-8"?>\n<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>ee7d616b9721575b32151ac9b7ed8a5819e3bb76741c4bd05b8076855ae7b789</ID><DisplayName>aws-deepengine-dev+docs</DisplayName></Owner><Buckets><Bucket><Name>amazon-braket-889863f741ec</Name><CreationDate>2021-02-18T23:09:39.000Z</CreationDate></Bucket><Bucket><Name>athena-paul-cb-bucket</Name><CreationDate>2021-04-02T20:27:26.000Z</CreationDate></Bucket><Bucket><Name>aws-athena-query-results-us-east-1-688520471316</Name><CreationDate>2021-04-22T19:13:37.000Z</CreationDate></Bucket><Bucket><Name>aws-cloudtrail-logs-688520471316-sagemaker-events-demo-de1644a1</Name><CreationDate>2020-09-01T20:19:09.000Z</CreationDate></Bucket><Bucket><Name>aws-glue-688520471316-us-west-2</Name><CreationDate>2021-05-28T19:35:20.000Z</CreationDate></Bucket><Bucket><Name>aws-logs-688520471316-us-east-2</Name><CreationDate>2020-09-23T15:34:11.000Z</CreationDate></Bucket><Bucket><Name>aws-redaction</Name><CreationDate>2021-05-07T20:47:34.000Z</CreationDate></Bucket><Bucket><Name>aws-use-case-churn</Name><CreationDate>2020-11-19T01:42:40.000Z</CreationDate></Bucket><Bucket><Name>bucket-1614624186</Name><CreationDate>2021-03-01T18:43:08.000Z</CreationDate></Bucket><Bucket><Name>bucket-1614626528</Name><CreationDate>2021-03-01T19:22:10.000Z</CreationDate></Bucket><Bucket><Name>bucket-1614627600</Name><CreationDate>2021-03-01T19:40:01.000Z</CreationDate></Bucket><Bucket><Name>bucket-1614627609</Name><CreationDate>2021-03-01T19:40:10.000Z</CreationDate></Bucket><Bucket><Name>cf-templates-1xpanbgqwkkin-us-west-2</Name><CreationDate>2020-10-27T23:17:48.000Z</CreationDate></Bucket><Bucket><Name>cloudtrail-dsoaws-688520471316</Name><CreationDate>2020-09-25T17:38:34.000Z</CreationDate></Bucket><Bucket><Name>demo-bucket-us-west-2-ngl</Name><CreationDate>2020-05-24T23:18:19.000Z</CreationDate></Bucket><Bucket><Name>do-not-delete-gatedgarden-audit-688520471316</Name><CreationDate>2021-05-24T02:06:21.000Z</CreationDate></Bucket><Bucket><Name>dsoaws-test-upload-688520471316</Name><CreationDate>2020-09-24T21:21:55.000Z</CreationDate></Bucket><Bucket><Name>elasticbeanstalk-us-east-1-688520471316</Name><CreationDate>2021-02-08T18:56:47.000Z</CreationDate></Bucket><Bucket><Name>elasticbeanstalk-us-west-2-688520471316</Name><CreationDate>2021-02-10T19:20:44.000Z</CreationDate></Bucket><Bucket><Name>example-notebooks-testing</Name><CreationDate>2021-04-22T01:35:17.000Z</CreationDate></Bucket><Bucket><Name>hongshan-sagemaker-experiments</Name><CreationDate>2021-04-13T21:24:26.000Z</CreationDate></Bucket><Bucket><Name>jashuang-sagemaker-5-22</Name><CreationDate>2020-05-22T18:30:19.000Z</CreationDate></Bucket><Bucket><Name>jashuang-sagemaker-model-monitor</Name><CreationDate>2020-07-06T18:06:51.000Z</CreationDate></Bucket><Bucket><Name>jashuang-test-sagemaker-6-25</Name><CreationDate>2020-06-25T17:24:03.000Z</CreationDate></Bucket><Bucket><Name>jashuang-test-sagemaker-useast1-6-26</Name><CreationDate>2020-06-26T23:03:29.000Z</CreationDate></Bucket><Bucket><Name>markhama-herring</Name><CreationDate>2020-09-02T18:56:30.000Z</CreationDate></Bucket><Bucket><Name>mohave-test-alexs</Name><CreationDate>2020-10-19T20:59:17.000Z</CreationDate></Bucket><Bucket><Name>neo-test-walkthrough-role</Name><CreationDate>2021-02-26T21:55:03.000Z</CreationDate></Bucket><Bucket><Name>ngl-tvm-emails</Name><CreationDate>2021-02-23T00:45:43.000Z</CreationDate></Bucket><Bucket><Name>ngl-us-west-2-aws-ses</Name><CreationDate>2021-05-01T00:51:28.000Z</CreationDate></Bucket><Bucket><Name>notebooks-hospital</Name><CreationDate>2021-02-16T23:40:21.000Z</CreationDate></Bucket><Bucket><Name>paddle-sentiment-model-867e38c2-de94-11ea-aa6f-4d59b2d4293b</Name><CreationDate>2020-08-15T01:13:30.000Z</CreationDate></Bucket><Bucket><Name>paddle-sentiment-model-9cee6b12-de90-11ea-b9be-bf3932e2a8f1</Name><CreationDate>2020-08-15T00:45:31.000Z</CreationDate></Bucket><Bucket><Name>paddle-sentiment-model-b49abfa4-e020-11ea-aa6f-4d59b2d4293b</Name><CreationDate>2020-08-17T00:29:28.000Z</CreationDate></Bucket><Bucket><Name>paddle-sentiment-model-c4af2f0c-e98e-11ea-bc5a-3bced4c2d5f6</Name><CreationDate>2020-08-29T00:30:02.000Z</CreationDate></Bucket><Bucket><Name>parsa-gt-bucket</Name><CreationDate>2021-05-21T17:12:06.000Z</CreationDate></Bucket><Bucket><Name>paul-cb-bucket</Name><CreationDate>2021-05-13T16:44:00.000Z</CreationDate></Bucket><Bucket><Name>pvre-patching-logs-688520471316-us-west-2</Name><CreationDate>2021-03-23T18:22:46.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-2021-03-19-21-03-12</Name><CreationDate>2021-03-19T21:03:14.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-2021-03-22-23-18-31</Name><CreationDate>2021-03-22T23:18:33.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-2021-03-31-22-18-15</Name><CreationDate>2021-03-31T22:18:17.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-2021-04-01-00-17-41</Name><CreationDate>2021-04-01T00:17:42.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-2021-05-13-03-23-46</Name><CreationDate>2021-05-13T03:23:48.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allup-alexs-1025</Name><CreationDate>2020-10-26T21:19:46.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-577db2b8-4644-4659-943f-73b88dbd6876</Name><CreationDate>2020-11-19T19:21:26.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-8df38291-ad4e-4986-94ba-a09e33ef2b54</Name><CreationDate>2020-11-03T18:09:53.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-a2b02e61-7f8c-455f-a89a-ffd574821d7c</Name><CreationDate>2020-11-02T20:16:57.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-alex-1027</Name><CreationDate>2020-10-28T04:54:24.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-b564d5c8-0bc0-4ae1-9d63-b9dfa766ad12</Name><CreationDate>2020-11-18T19:07:53.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-ben</Name><CreationDate>2020-11-13T00:00:59.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-d2bdbe05-d9c3-43f7-af38-18e00a4a3c6b</Name><CreationDate>2020-11-14T20:30:22.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-allupdemo-ff3c3496-0254-46d9-a5b7-bc10b28a63c8</Name><CreationDate>2020-10-28T20:22:18.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-builtin-ic-0daf6fc5-9e8c-475c-ad90-4d8ab0c17ec8</Name><CreationDate>2020-10-29T23:11:36.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-edge-manager-demo</Name><CreationDate>2021-03-29T16:48:15.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-edge-manager-demo-notebooks</Name><CreationDate>2021-04-01T17:53:22.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-experiments-us-west-2-688520471316</Name><CreationDate>2020-10-28T02:13:56.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-glue-example-688520471316-us-west-2</Name><CreationDate>2021-05-28T19:37:21.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-model-artifacts-dev</Name><CreationDate>2020-11-14T00:51:18.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-mohave-clarissak</Name><CreationDate>2020-11-24T18:29:46.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-notebook-feedback</Name><CreationDate>2021-04-08T22:53:14.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-prebuilt-ic-7a00f320-680f-4d7f-b9d9-58294ba29635</Name><CreationDate>2020-10-21T08:50:06.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-prebuilt-ic-8a6a4143-d2e3-4d40-9a67-866c926d1252</Name><CreationDate>2020-10-22T19:45:28.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-project-p-mucmtf87baoc</Name><CreationDate>2021-03-18T20:17:12.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-project-p-w6rcflcusq3z</Name><CreationDate>2021-03-20T14:28:26.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-pytorch-ic-4b322469-e415-4712-840c-027e79890584</Name><CreationDate>2020-10-21T09:01:14.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-pytorch-ic-f360755a-978c-4d72-bb19-00b1c02353db</Name><CreationDate>2020-10-22T20:58:51.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-studio-688520471316-09o2x16efvbh</Name><CreationDate>2020-05-29T15:09:46.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-studio-688520471316-0dc6dz5z87uw</Name><CreationDate>2021-03-20T14:01:58.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-studio-688520471316-8rvgdl7qlzv</Name><CreationDate>2020-02-14T18:10:25.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-studio-us-east-2-688520471316</Name><CreationDate>2020-02-14T18:28:50.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-studio-us-west-2-688520471316</Name><CreationDate>2021-05-11T18:04:56.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-studio-us-west-2-ngl</Name><CreationDate>2020-06-07T04:23:02.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-tensorflow-ic-694406da-11c2-454c-ad6f-8ef83a25f88b</Name><CreationDate>2020-10-21T08:59:29.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-tensorflow-ic-7c0063e0-7bfc-4cad-a13a-5bdac080c242</Name><CreationDate>2020-10-22T19:46:50.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-us-east-1-688520471316</Name><CreationDate>2020-09-24T20:00:46.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-us-east-2-688520471316</Name><CreationDate>2020-11-09T14:14:23.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-us-west-1-688520471316</Name><CreationDate>2020-10-20T20:57:55.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-us-west-2-688520471316</Name><CreationDate>2020-07-01T00:38:18.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-yavapai-688520471316</Name><CreationDate>2020-10-13T16:59:49.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-yavapai-alexs2</Name><CreationDate>2020-10-27T02:23:17.000Z</CreationDate></Bucket><Bucket><Name>sagemaker-yavapai-bena</Name><CreationDate>2020-10-14T13:31:42.000Z</CreationDate></Bucket><Bucket><Name>sagmaker-mohave-bena</Name><CreationDate>2020-10-14T17:18:43.000Z</CreationDate></Bucket><Bucket><Name>secure-bucket-vpc</Name><CreationDate>2021-03-16T00:45:30.000Z</CreationDate></Bucket><Bucket><Name>secure-bucket-vpc-1</Name><CreationDate>2021-03-16T01:07:33.000Z</CreationDate></Bucket><Bucket><Name>ssm-onboarding-bucket-688520471316-us-west-2</Name><CreationDate>2021-03-23T18:22:36.000Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>'
DEBUG:botocore.hooks:Event needs-retry.s3.ListBuckets: calling handler <botocore.retryhandler.RetryHandler object at 0x7f28e100ae80>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:botocore.hooks:Event needs-retry.s3.ListBuckets: calling handler <bound method S3RegionRedirector.redirect_from_error of <botocore.utils.S3RegionRedirector object at 0x7f28e100ae48>>
DEBUG:botocore.hooks:Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f2945acc9d8>
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function add_generate_presigned_post at 0x7f2945b80730>
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function lazy_call.<locals>._handler at 0x7f29297a36a8>
DEBUG:botocore.hooks:Event creating-client-class.s3: calling handler <function add_generate_presigned_url at 0x7f2945b80510>
DEBUG:botocore.endpoint:Setting s3 timeout as (60, 60)
DEBUG:botocore.client:Registering retry handlers for service: s3
DEBUG:boto3.resources.factory:Loading s3:s3
DEBUG:boto3.resources.factory:Loading s3:Object
DEBUG:botocore.hooks:Event creating-resource-class.s3.Object: calling handler <function lazy_call.<locals>._handler at 0x7f28ecbc4048>
DEBUG:s3transfer.utils:Acquiring 0
DEBUG:s3transfer.tasks:UploadSubmissionTask(transfer_id=0, {'transfer_future': <s3transfer.futures.TransferFuture object at 0x7f28e0faa3c8>}) about to wait for the following futures []
DEBUG:s3transfer.tasks:UploadSubmissionTask(transfer_id=0, {'transfer_future': <s3transfer.futures.TransferFuture object at 0x7f28e0faa3c8>}) done waiting for dependent futures
DEBUG:s3transfer.tasks:Executing task UploadSubmissionTask(transfer_id=0, {'transfer_future': <s3transfer.futures.TransferFuture object at 0x7f28e0faa3c8>}) with kwargs {'client': <botocore.client.S3 object at 0x7f28e1198978>, 'config': <boto3.s3.transfer.TransferConfig object at 0x7f28e1033d68>, 'osutil': <s3transfer.utils.OSUtils object at 0x7f28e1033e10>, 'request_executor': <s3transfer.futures.BoundedExecutor object at 0x7f28e1033ba8>, 'transfer_future': <s3transfer.futures.TransferFuture object at 0x7f28e0faa3c8>}
DEBUG:s3transfer.futures:Submitting task PutObjectTask(transfer_id=0, {'bucket': 'sagemaker-us-west-2-688520471316', 'key': 'model/model.tar.gz', 'extra_args': {}}) to executor <s3transfer.futures.BoundedExecutor object at 0x7f28e1033ba8> for transfer request: 0.
DEBUG:s3transfer.utils:Acquiring 0
DEBUG:s3transfer.tasks:PutObjectTask(transfer_id=0, {'bucket': 'sagemaker-us-west-2-688520471316', 'key': 'model/model.tar.gz', 'extra_args': {}}) about to wait for the following futures []
DEBUG:s3transfer.tasks:PutObjectTask(transfer_id=0, {'bucket': 'sagemaker-us-west-2-688520471316', 'key': 'model/model.tar.gz', 'extra_args': {}}) done waiting for dependent futures
DEBUG:s3transfer.tasks:Executing task PutObjectTask(transfer_id=0, {'bucket': 'sagemaker-us-west-2-688520471316', 'key': 'model/model.tar.gz', 'extra_args': {}}) with kwargs {'client': <botocore.client.S3 object at 0x7f28e1198978>, 'fileobj': <s3transfer.utils.ReadFileChunk object at 0x7f28e0faa630>, 'bucket': 'sagemaker-us-west-2-688520471316', 'key': 'model/model.tar.gz', 'extra_args': {}}
DEBUG:botocore.hooks:Event before-parameter-build.s3.PutObject: calling handler <function validate_ascii_metadata at 0x7f2945af2b70>
DEBUG:botocore.hooks:Event before-parameter-build.s3.PutObject: calling handler <function sse_md5 at 0x7f2945af2048>
DEBUG:botocore.hooks:Event before-parameter-build.s3.PutObject: calling handler <function convert_body_to_file_like_object at 0x7f2945af0488>
DEBUG:botocore.hooks:Event before-parameter-build.s3.PutObject: calling handler <function validate_bucket_name at 0x7f2945aecf28>
DEBUG:botocore.hooks:Event before-parameter-build.s3.PutObject: calling handler <bound method S3RegionRedirector.redirect_from_cache of <botocore.utils.S3RegionRedirector object at 0x7f28e0fe1ba8>>
DEBUG:botocore.hooks:Event before-parameter-build.s3.PutObject: calling handler <bound method S3ArnParamHandler.handle_arn of <botocore.utils.S3ArnParamHandler object at 0x7f28e0fe1160>>
DEBUG:botocore.hooks:Event before-parameter-build.s3.PutObject: calling handler <function generate_idempotent_uuid at 0x7f2945aecd90>
DEBUG:botocore.hooks:Event before-call.s3.PutObject: calling handler <function conditionally_calculate_md5 at 0x7f2945c67378>
DEBUG:s3transfer.utils:Releasing acquire 0/None
DEBUG:botocore.hooks:Event before-call.s3.PutObject: calling handler <function add_expect_header at 0x7f2945af22f0>
DEBUG:botocore.handlers:Adding expect 100 continue header to request.
DEBUG:botocore.hooks:Event before-call.s3.PutObject: calling handler <bound method S3RegionRedirector.set_request_url of <botocore.utils.S3RegionRedirector object at 0x7f28e0fe1ba8>>
DEBUG:botocore.hooks:Event before-call.s3.PutObject: calling handler <function inject_api_version_header_if_needed at 0x7f2945af0598>
DEBUG:botocore.endpoint:Making request for OperationModel(name=PutObject) with params: {'url_path': '/sagemaker-us-west-2-688520471316/model/model.tar.gz', 'query_string': {}, 'method': 'PUT', 'headers': {'User-Agent': 'Boto3/1.16.36 Python/3.6.10 Linux/4.15.0-1065-aws Botocore/1.19.9 Resource', 'Content-MD5': '6OcC2Sl6GXHJtuTC+aL/Sg==', 'Expect': '100-continue'}, 'body': <s3transfer.utils.ReadFileChunk object at 0x7f28e0faa630>, 'url': 'https://s3.us-west-2.amazonaws.com/sagemaker-us-west-2-688520471316/model/model.tar.gz', 'context': {'client_region': 'us-west-2', 'client_config': <botocore.config.Config object at 0x7f28e0fe1ef0>, 'has_streaming_input': True, 'auth_type': None, 'signing': {'bucket': 'sagemaker-us-west-2-688520471316'}}}
DEBUG:botocore.hooks:Event request-created.s3.PutObject: calling handler <function signal_not_transferring at 0x7f28e1060488>
DEBUG:botocore.hooks:Event request-created.s3.PutObject: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x7f28e0fe1f28>>
DEBUG:botocore.hooks:Event choose-signer.s3.PutObject: calling handler <bound method ClientCreator._default_s3_presign_to_sigv2 of <botocore.client.ClientCreator object at 0x7f28e10d3240>>
DEBUG:botocore.hooks:Event choose-signer.s3.PutObject: calling handler <function set_operation_specific_signer at 0x7f2945aecc80>
DEBUG:botocore.hooks:Event before-sign.s3.PutObject: calling handler <bound method S3EndpointSetter.set_endpoint of <botocore.utils.S3EndpointSetter object at 0x7f28e0fe1390>>
DEBUG:botocore.utils:Defaulting to S3 virtual host style addressing with path style addressing fallback.
DEBUG:botocore.utils:Checking for DNS compatible bucket for: https://s3.us-west-2.amazonaws.com/sagemaker-us-west-2-688520471316/model/model.tar.gz
DEBUG:botocore.utils:URI updated to: https://sagemaker-us-west-2-688520471316.s3.us-west-2.amazonaws.com/model/model.tar.gz
DEBUG:botocore.auth:Calculating signature using v4 auth.
DEBUG:botocore.auth:CanonicalRequest:
PUT
/model/model.tar.gz

content-md5:6OcC2Sl6GXHJtuTC+aL/Sg==
host:sagemaker-us-west-2-688520471316.s3.us-west-2.amazonaws.com
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-date:20210604T181420Z
x-amz-security-token:IQoJb3JpZ2luX2VjEGIaCXVzLXdlc3QtMiJHMEUCIEOfqGya0Mn6jr1RVpzCFv+7vrC9K7EsGTA4IRda73esAiEA2VK1eLYhomSbeYMrIVDpIafH2ec3IvlMf5gTJRLxeoIq+gMIGxADGgw2ODg1MjA0NzEzMTYiDEtvG1DeRLaCoX6xpSrXA2N8QmbkLOBVAwgfv8v3tAih8PWY3tZI7McnzZ1VNy2KTcp2gqchjElFIxq4VOH1QSbIRd8WG7iCr8DcZCC27RZo6SIC5ip12vJorLf3vgkhhqeQXIdpEDSjdDHyrOuLESI1J/ZPrn5Aor8NeMqEoB1kDAFT795swBulfVkpFSSjtRehAEkoZxOovwHsOiM/INY8Kj0fdH0cpQ+hSVetTwEedelGLyd03n400y4ewekmCdcAnp4HaPurSLet3ewDL30KmZGwqx3gpz8eR5CiZR+V+symk05SlTnX797VvAPfGWs+eHyfAqpMfKnG+XD9xjQxnfo0AahGdQ2Uvnvxz4Oe0Cwtx3yrHXyL/dPk6taaIZp07zvrMnEYwxG7k6QcA70x9nGZ3GMEpg9u7HWMB63NBv2OQfyLP9U+cqTjPoljR/Q9TaABBBn6YYqLqA7yDcJJ13ZhrqL/u9T0ag3rkaG3iOSGJWE+IrzXXmhI5JnJFxi/a+9wRLtu1Q66VES8t8j0b17aItOOKP4tVshyQ8CGTgkYjilSxWOzEYIJlz1c0NEOzy9/dVVqsjXgvG2kX2USqSnmIDmNgzRO4DAKuOnJYIM6PevT78I96OPE8Zv0peBzggJ9VzDH0emFBjqlAZuaNAdTVF7vs3OcAV+mbX/qa9vaL61mY+d2Tu+ZzlvXm/e4fow8nQsym0ITCa/xIwjpecfOWRoD/DTIQWpMZZVQZXK3omBIBkNz0tyhCdJUDgg5MFku9eagwvSsl2GjHPb0pW0gXVdhUpeTsz2k+gkZC242DF1FkoZOtqdBf9QZyG315WEUssMqjYAQhj867bF5RazMCE/wZ2uEnN2gKgL/DkqtLA==

content-md5;host;x-amz-content-sha256;x-amz-date;x-amz-security-token
UNSIGNED-PAYLOAD
DEBUG:botocore.auth:StringToSign:
AWS4-HMAC-SHA256
20210604T181420Z
20210604/us-west-2/s3/aws4_request
39e0086261fd27243b7e3ab5a1eecbafc0e4a87b1bb6a31b71fff5712d4bd5d7
DEBUG:botocore.auth:Signature:
5442f49204d851bd2bf165e821b9a01d29a6d88ac88cd4eb8666d66561e933ad
DEBUG:botocore.hooks:Event request-created.s3.PutObject: calling handler <function signal_transferring at 0x7f28e1060510>
DEBUG:botocore.endpoint:Sending http request: <AWSPreparedRequest stream_output=False, method=PUT, url=https://sagemaker-us-west-2-688520471316.s3.us-west-2.amazonaws.com/model/model.tar.gz, headers={'User-Agent': b'Boto3/1.16.36 Python/3.6.10 Linux/4.15.0-1065-aws Botocore/1.19.9 Resource', 'Content-MD5': b'6OcC2Sl6GXHJtuTC+aL/Sg==', 'Expect': b'100-continue', 'X-Amz-Date': b'20210604T181420Z', 'X-Amz-Security-Token': b'IQoJb3JpZ2luX2VjEGIaCXVzLXdlc3QtMiJHMEUCIEOfqGya0Mn6jr1RVpzCFv+7vrC9K7EsGTA4IRda73esAiEA2VK1eLYhomSbeYMrIVDpIafH2ec3IvlMf5gTJRLxeoIq+gMIGxADGgw2ODg1MjA0NzEzMTYiDEtvG1DeRLaCoX6xpSrXA2N8QmbkLOBVAwgfv8v3tAih8PWY3tZI7McnzZ1VNy2KTcp2gqchjElFIxq4VOH1QSbIRd8WG7iCr8DcZCC27RZo6SIC5ip12vJorLf3vgkhhqeQXIdpEDSjdDHyrOuLESI1J/ZPrn5Aor8NeMqEoB1kDAFT795swBulfVkpFSSjtRehAEkoZxOovwHsOiM/INY8Kj0fdH0cpQ+hSVetTwEedelGLyd03n400y4ewekmCdcAnp4HaPurSLet3ewDL30KmZGwqx3gpz8eR5CiZR+V+symk05SlTnX797VvAPfGWs+eHyfAqpMfKnG+XD9xjQxnfo0AahGdQ2Uvnvxz4Oe0Cwtx3yrHXyL/dPk6taaIZp07zvrMnEYwxG7k6QcA70x9nGZ3GMEpg9u7HWMB63NBv2OQfyLP9U+cqTjPoljR/Q9TaABBBn6YYqLqA7yDcJJ13ZhrqL/u9T0ag3rkaG3iOSGJWE+IrzXXmhI5JnJFxi/a+9wRLtu1Q66VES8t8j0b17aItOOKP4tVshyQ8CGTgkYjilSxWOzEYIJlz1c0NEOzy9/dVVqsjXgvG2kX2USqSnmIDmNgzRO4DAKuOnJYIM6PevT78I96OPE8Zv0peBzggJ9VzDH0emFBjqlAZuaNAdTVF7vs3OcAV+mbX/qa9vaL61mY+d2Tu+ZzlvXm/e4fow8nQsym0ITCa/xIwjpecfOWRoD/DTIQWpMZZVQZXK3omBIBkNz0tyhCdJUDgg5MFku9eagwvSsl2GjHPb0pW0gXVdhUpeTsz2k+gkZC242DF1FkoZOtqdBf9QZyG315WEUssMqjYAQhj867bF5RazMCE/wZ2uEnN2gKgL/DkqtLA==', 'X-Amz-Content-SHA256': b'UNSIGNED-PAYLOAD', 'Authorization': b'AWS4-HMAC-SHA256 Credential=ASIA2ATYEUMKLLIXRTUU/20210604/us-west-2/s3/aws4_request, SignedHeaders=content-md5;host;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=5442f49204d851bd2bf165e821b9a01d29a6d88ac88cd4eb8666d66561e933ad', 'Content-Length': '411057'}>
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): sagemaker-us-west-2-688520471316.s3.us-west-2.amazonaws.com:443
DEBUG:botocore.awsrequest:Waiting for 100 Continue response.
DEBUG:botocore.awsrequest:100 Continue response seen, now sending request body.
DEBUG:urllib3.connectionpool:https://sagemaker-us-west-2-688520471316.s3.us-west-2.amazonaws.com:443 "PUT /model/model.tar.gz HTTP/1.1" 200 0
DEBUG:botocore.parsers:Response headers: {'x-amz-id-2': '6AlgGK5qoM4mr84SFnBI+iireLd4t4pULjimy92s7CRnxEwWmqV8ajPT2M9E3qbHGSb46mMORfA=', 'x-amz-request-id': '40XGMFVJ7NDWR6DB', 'Date': 'Fri, 04 Jun 2021 18:14:21 GMT', 'ETag': '"e8e702d9297a1971c9b6e4c2f9a2ff4a"', 'Content-Length': '0', 'Server': 'AmazonS3'}
DEBUG:botocore.parsers:Response body:
b''
DEBUG:botocore.hooks:Event needs-retry.s3.PutObject: calling handler <botocore.retryhandler.RetryHandler object at 0x7f28e0fe1a90>
DEBUG:botocore.retryhandler:No retry needed.
DEBUG:botocore.hooks:Event needs-retry.s3.PutObject: calling handler <bound method S3RegionRedirector.redirect_from_error of <botocore.utils.S3RegionRedirector object at 0x7f28e0fe1ba8>>
DEBUG:s3transfer.utils:Releasing acquire 0/None

Use the sagemaker.mxnet.model.MXNetModel to import the model into SageMaker that can be deployed. We need the location of the S3 bucket where we have the model, the role for authentication and the entry_point where the model defintion is stored (mnist.py). The import call is the following:

[9]:
from sagemaker.mxnet.model import MXNetModel

sagemaker_model = MXNetModel(
    model_data="s3://" + sagemaker_session.default_bucket() + "/model/model.tar.gz",
    role=role,
    framework_version='1.7.0',
    py_version='py3',
    entry_point="mnist.py",
)

Create endpoint

Now the model is ready to be deployed at a SageMaker endpoint. We can use the sagemaker.mxnet.model.MXNetModel.deploy method to do this. Unless you have created or prefer other instances, we recommend using 1 'ml.c4.xlarge' instance for this training. These are supplied as arguments.

[10]:
import logging

logging.getLogger().setLevel(logging.WARNING)

predictor = sagemaker_model.deploy(initial_instance_count=1, instance_type="ml.m4.xlarge")
------!

Validate the endpoint for use

You will ping the endpoint with the test images from MNIST.

[20]:
import gzip
import numpy as np
import random

with gzip.open("t10k-images-idx3-ubyte.gz", "rb") as f:
    images = np.frombuffer(f.read(), np.uint8, offset=16).reshape(-1, 28, 28).astype(np.float32)

mask = random.sample(range(len(images)), 16) # randomly select some of the test images
mask = np.array(mask, dtype=np.int)

data = images[mask]
[21]:
response = predictor.predict(data)
print("Raw prediction result:")
print(response)
print()

labeled_predictions = list(zip(range(10), response[0]))
print("Labeled predictions: ")
print(labeled_predictions)
print()

labeled_predictions.sort(key=lambda label_and_prob: 1.0 - label_and_prob[1])
print("Most likely answer: {}".format(labeled_predictions[0]))
Raw prediction result:
[[0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 2.96591231574439e-08, 0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 2.6243371788733024e-23, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]

Labeled predictions:
[(0, 0.0), (1, 0.0), (2, 0.0), (3, 1.0), (4, 0.0), (5, 0.0), (6, 0.0), (7, 0.0), (8, 0.0), (9, 0.0)]

Most likely answer: (3, 1.0)

(Optional) Delete the Endpoint

[26]:
sagemaker_session.delete_endpoint(
    endpoint_name=predictor.endpoint_name
)

If you do not want continied use of the endpoint, you can remove it. Remember, open endpoints are charged. If this is a simple test or practice, it is recommended to delete them.

Clear all stored model data so that we don’t overwrite them the next time.

[ ]:
os.remove("model.tar.gz")
import shutil

shutil.rmtree("model")