Amazon SageMaker
Developer Guide

Step 1: Create a Notebook and Initialize Variables

In this section, you create a Jupyter notebook in your Amazon SageMaker notebook instance and initialize variables.

  1. Follow the instructions in Step 1: Setting Up to create the S3 bucket and IAM role.

    For simplicity, we suggest that you use one S3 bucket to store both the training code and the results of model training.

  2. Create the notebook.

    1. If you haven't already done so, sign in to the Amazon SageMaker console at

    2. Open the notebook instance by choosing Open next to its name. The Jupyter notebook server page appears.

    3. To create a notebook, choose Files, New, and conda_mxnet_p36. This pre-installed environment includes the default Anaconda installation, Python 3, and MXNet.

    4. Name the notebook.

  3. To initialize variables, copy, paste, and run the following code in your notebook. Provide the name of the S3 bucket that contains your custom code. The get_execution_role function retrieves the IAM role you created at the time of creating your notebook instance. You can use the bucket that you created in Step 1: Setting Up, or create a new bucket.

    from sagemaker import get_execution_role #Bucket location to save your custom code in tar.gz format. custom_code_upload_location = 's3://your-bucket-name/customcode/mxnet' #Bucket location where results of model training are saved. model_artifacts_location = 's3://your-bucket-name/artifacts' #IAM execution role that gives Amazon SageMaker access to resources in your AWS account. #We can use the Amazon SageMaker Python SDK to get the role from our notebook environment. role = get_execution_role()

Next Step

Step 2: Train a Model on Amazon SageMaker Using Apache MXNet Custom Code

On this page: