Estimators

A high level interface for SageMaker training

class sagemaker.estimator.EstimatorBase(role=None, instance_count=None, instance_type=None, keep_alive_period_in_seconds=None, volume_size=30, volume_kms_key=None, max_run=86400, input_mode='File', output_path=None, output_kms_key=None, base_job_name=None, sagemaker_session=None, tags=None, subnets=None, security_group_ids=None, model_uri=None, model_channel_name='model', metric_definitions=None, encrypt_inter_container_traffic=None, use_spot_instances=False, max_wait=None, checkpoint_s3_uri=None, checkpoint_local_path=None, rules=None, debugger_hook_config=None, tensorboard_output_config=None, enable_sagemaker_metrics=None, enable_network_isolation=None, profiler_config=None, disable_profiler=None, environment=None, max_retry_attempts=None, source_dir=None, git_config=None, hyperparameters=None, container_log_level=20, code_location=None, entry_point=None, dependencies=None, instance_groups=None, training_repository_access_mode=None, training_repository_credentials_provider_arn=None, enable_infra_check=None, container_entry_point=None, container_arguments=None, disable_output_compression=False, enable_remote_debug=None, enable_session_tag_chaining=None, **kwargs)

Bases: object

Handle end-to-end Amazon SageMaker training and deployment tasks.

For introduction to model training and deployment, see http://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html

Subclasses must define a way to determine what image to use for training, what hyperparameters to use, and how to create an appropriate predictor instance.

Initialize an EstimatorBase instance.

Parameters
  • role (str) – An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. After the endpoint is created, the inference code might use the IAM role, if it needs to access an AWS resource.

  • instance_count (int or PipelineVariable) – Number of Amazon EC2 instances to use for training. Required if instance_groups is not set.

  • instance_type (str or PipelineVariable) – Type of EC2 instance to use for training, for example, 'ml.c4.xlarge'. Required if instance_groups is not set.

  • keep_alive_period_in_seconds (int) – The duration of time in seconds to retain configured resources in a warm pool for subsequent training jobs (default: None).

  • volume_size (int or PipelineVariable) –

    Size in GB of the storage volume to use for storing input and output data during training (default: 30).

    Must be large enough to store training data if File mode is used, which is the default mode.

    When you use an ML instance with the EBS-only storage option such as ml.c5 and ml.p2, you must define the size of the EBS volume through the volume_size parameter in the estimator class.

    Note

    When you use an ML instance with NVMe SSD volumes such as ml.p4d, ml.g4dn, and ml.g5, do not include this parameter in the estimator configuration. If you use one of those ML instance types, SageMaker doesn’t provision Amazon EBS General Purpose SSD (gp2) storage nor take this parameter to adjust the NVMe instance storage. Available storage is fixed to the NVMe instance storage capacity. SageMaker configures storage paths for training datasets, checkpoints, model artifacts, and outputs to use the entire capacity of the instance storage.

    Note that if you include this parameter and specify a number that exceeds the size of the NVMe volume attached to the instance type, SageMaker returns an Invalid VolumeSizeInGB error.

    To look up instance types and their instance storage types and volumes, see Amazon EC2 Instance Types.

    To find the default local paths defined by the SageMaker training platform, see Amazon SageMaker Training Storage Folders for Training Datasets, Checkpoints, Model Artifacts, and Outputs.

  • volume_kms_key (str or PipelineVariable) – Optional. KMS key ID for encrypting EBS volume attached to the training instance (default: None).

  • max_run (int or PipelineVariable) – Timeout in seconds for training (default: 24 * 60 * 60). After this amount of time Amazon SageMaker terminates the job regardless of its current status.

  • input_mode (str or PipelineVariable) – The input mode that the algorithm supports (default: ‘File’). Valid modes: ‘File’ - Amazon SageMaker copies the training dataset from the S3 location to a local directory. ‘Pipe’ - Amazon SageMaker streams data directly from S3 to the container via a Unix-named pipe. ‘FastFile’ - Amazon SageMaker streams data from S3 on demand instead of downloading the entire dataset before training begins. This argument can be overriden on a per-channel basis using sagemaker.inputs.TrainingInput.input_mode.

  • output_path (str or PipelineVariable) – S3 location for saving the training result (model artifacts and output files). If not specified, results are stored to a default bucket. If the bucket with the specific name does not exist, the estimator creates the bucket during the fit() method execution. file:// urls are used for local mode. For example: ‘file://model/’ will save to the model folder in the current directory.

  • output_kms_key (str or PipelineVariable) – Optional. KMS key ID for encrypting the training output (default: Your IAM role’s KMS key for Amazon S3). If you don’t provide a KMS key ID, Amazon SageMaker uses the default KMS key for Amazon S3 of the account linked to your IAM role.

  • base_job_name (str) – Prefix for training job name when the fit() method launches. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

  • sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain.

  • tags (Optional[Tags]) – Tags for labeling a training job. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.

  • subnets (list[str] or list[PipelineVariable]) – List of subnet ids. If not specified training job will be created without VPC config.

  • security_group_ids (list[str] or list[PipelineVariable]) – List of security group ids. If not specified training job will be created without VPC config.

  • model_uri (str) –

    URI where a pre-trained model is stored, either locally or in S3 (default: None). If specified, the estimator will create a channel pointing to the model so the training job can download it. This model can be a ‘model.tar.gz’ from a previous training job, or other artifacts coming from a different source.

    In local mode, this should point to the path in which the model is located and not the file itself, as local Docker containers will try to mount the URI as a volume.

    More information: https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html#td-deserialization

  • model_channel_name (str or PipelineVariable) – Name of the channel where ‘model_uri’ will be downloaded (default: ‘model’).

  • metric_definitions (list[dict[str, str] or list[dict[str, PipelineVariable]]) – A list of dictionaries that defines the metric(s) used to evaluate the training jobs. Each dictionary contains two keys: ‘Name’ for the name of the metric, and ‘Regex’ for the regular expression used to extract the metric from the logs. This should be defined only for jobs that don’t use an Amazon algorithm.

  • encrypt_inter_container_traffic (bool or PipelineVariable) – Specifies whether traffic between training containers is encrypted for the training job (default: False).

  • use_spot_instances (bool or PipelineVariable) – Specifies whether to use SageMaker Managed Spot instances for training. If enabled then the max_wait arg should also be set. More information: https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html (default: False).

  • max_wait (int or PipelineVariable) – Timeout in seconds waiting for spot training job (default: None). After this amount of time Amazon SageMaker will stop waiting for managed spot training job to complete (default: None).

  • checkpoint_s3_uri (str or PipelineVariable) – The S3 URI in which to persist checkpoints that the algorithm persists (if any) during training. (default: None).

  • checkpoint_local_path (str or PipelineVariable) – The local path that the algorithm writes its checkpoints to. SageMaker will persist all files under this path to checkpoint_s3_uri continually during training. On job startup the reverse happens - data from the s3 location is downloaded to this path before the algorithm is started. If the path is unset then SageMaker assumes the checkpoints will be provided under /opt/ml/checkpoints/. (default: None).

  • rules (list[RuleBase]) – A list of RuleBase objects used to define SageMaker Debugger rules for real-time analysis (default: None). For more information, see Continuous analyses through rules.

  • debugger_hook_config (DebuggerHookConfig or bool) – Configuration for how debugging information is emitted with SageMaker Debugger. If not specified, a default one is created using the estimator’s output_path, unless the region does not support SageMaker Debugger. To disable SageMaker Debugger, set this parameter to False. For more information, see Capture real-time debugging data during model training in Amazon SageMaker.

  • tensorboard_output_config (TensorBoardOutputConfig) – Configuration for customizing debugging visualization using TensorBoard (default: None). For more information, see Capture real time tensorboard data.

  • enable_sagemaker_metrics (bool or PipelineVariable) – enable SageMaker Metrics Time Series. For more information, see AlgorithmSpecification API. (default: None).

  • enable_network_isolation (bool or PipelineVariable) – Specifies whether container will run in network isolation mode (default: False). Network isolation mode restricts the container access to outside networks (such as the Internet). The container does not make any inbound or outbound network calls. Also known as Internet-free mode.

  • profiler_config (ProfilerConfig) – Configuration for how SageMaker Debugger collects monitoring and profiling information from your training job. If not specified, a default configuration is created using the estimator’s output_path, unless the region does not support SageMaker Debugger. To disable SageMaker Debugger monitoring and profiling, set the disable_profiler parameter to True.

  • disable_profiler (bool) – Specifies whether Debugger monitoring and profiling will be disabled (default: False).

  • environment (dict[str, str] or dict[str, PipelineVariable]) – Environment variables to be set for use during training job (default: None)

  • max_retry_attempts (int or PipelineVariable) – The number of times to move a job to the STARTING status. You can specify between 1 and 30 attempts. If the value of attempts is greater than zero, the job is retried on InternalServerFailure the same number of attempts as the value. You can cap the total duration for your job by setting max_wait and max_run (default: None)

  • source_dir (str or PipelineVariable) –

    The absolute, relative, or S3 URI Path to a directory with any other training source code dependencies aside from the entry point file (default: None). If source_dir is an S3 URI, it must point to a tar.gz file. The structure within this directory is preserved when training on Amazon SageMaker. If ‘git_config’ is provided, ‘source_dir’ should be a relative location to a directory in the Git repo. With the following GitHub repo directory structure:

    |----- README.md
    |----- src
             |----- train.py
             |----- test.py
    

    if you need ‘train.py’ as the entry point and ‘test.py’ as the training source code, you can assign entry_point=’train.py’ and source_dir=’src’.

  • git_config (dict[str, str]) –

    Git configurations used for cloning files, including repo, branch, commit, 2FA_enabled, username, password, and token. The repo field is required. All other fields are optional. repo specifies the Git repository where your training script is stored. If you don’t provide branch, the default value ‘master’ is used. If you don’t provide commit, the latest commit in the specified branch is used. For example, the following config:

    git_config = {
        'repo': 'https://github.com/aws/sagemaker-python-sdk.git',
        'branch': 'test-branch-git-config',
        'commit': '329bfcf884482002c05ff7f44f62599ebc9f445a'
    }
    

    results in cloning the repo specified in ‘repo’, then checking out the ‘master’ branch, and checking out the specified commit. 2FA_enabled, username, password, and token are used for authentication. For GitHub (or other Git) accounts, set 2FA_enabled to ‘True’ if two-factor authentication is enabled for the account, otherwise set it to ‘False’. If you do not provide a value for 2FA_enabled, a default value of ‘False’ is used. CodeCommit does not support two-factor authentication, so do not provide “2FA_enabled” with CodeCommit repositories.

    For GitHub and other Git repos, when SSH URLs are provided, it doesn’t matter whether 2FA is enabled or disabled. You should either have no passphrase for the SSH key pairs or have the ssh-agent configured so that you will not be prompted for the SSH passphrase when you run the ‘git clone’ command with SSH URLs. When HTTPS URLs are provided, if 2FA is disabled, then either token or username and password are be used for authentication if provided. Token is prioritized. If 2FA is enabled, only token is used for authentication if provided. If required authentication info is not provided, the SageMaker Python SDK attempts to use local credentials to authenticate. If that fails, an error message is thrown.

    For CodeCommit repos, 2FA is not supported, so ‘2FA_enabled’ should not be provided. There is no token in CodeCommit, so token should also not be provided. When repo is an SSH URL, the requirements are the same as GitHub repos. When repo is an HTTPS URL, username and password are used for authentication if they are provided. If they are not provided, the SageMaker Python SDK attempts to use either the CodeCommit credential helper or local credential storage for authentication.

  • hyperparameters (dict[str, str] or dict[str, PipelineVariable]) –

    A dictionary containing the hyperparameters to initialize this estimator with. (Default: None).

    Caution

    You must not include any security-sensitive information, such as account access IDs, secrets, and tokens, in the dictionary for configuring hyperparameters. SageMaker rejects the training job request and returns an validation error for detected credentials, if such user input is found.

  • container_log_level (int or PipelineVariable) – The log level to use within the container (default: logging.INFO). Valid values are defined in the Python logging module.

  • code_location (str) – The S3 prefix URI where custom code is uploaded (default: None). You must not include a trailing slash because a string prepended with a “/” is appended to code_location. The code file uploaded to S3 is ‘code_location/job-name/source/sourcedir.tar.gz’. If not specified, the default code location is ‘s3://output_bucket/job-name/’.

  • entry_point (str or PipelineVariable) –

    The absolute or relative path to the local Python source file that should be executed as the entry point to training. (Default: None). If source_dir is specified, then entry_point must point to a file located at the root of source_dir. If ‘git_config’ is provided, ‘entry_point’ should be a relative location to the Python source file in the Git repo.

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- train.py
    >>>         |----- test.py
    

    You can assign entry_point=’src/train.py’.

  • dependencies (list[str]) –

    A list of absolute or relative paths to directories with any additional libraries that should be exported to the container (default: []). The library folders are copied to SageMaker in the same folder where the entrypoint is copied. If ‘git_config’ is provided, ‘dependencies’ should be a list of relative locations to directories with any additional libraries needed in the Git repo.

    Example

    The following Estimator call:

    >>> Estimator(entry_point='train.py',
    ...           dependencies=['my/libs/common', 'virtual-env'])
    

    results in the following structure inside the container:

    >>> $ ls
    
    >>> opt/ml/code
    >>>     |------ train.py
    >>>     |------ common
    >>>     |------ virtual-env
    

    This is not supported with “local code” in Local Mode.

  • instance_groups (list[sagemaker.instance_group.InstanceGroup]) –

    Optional. A list of InstanceGroup objects for launching a training job with a heterogeneous cluster. For example:

    instance_groups=[
        sagemaker.InstanceGroup(
            'instance_group_name_1', 'ml.p3dn.24xlarge', 64),
        sagemaker.InstanceGroup(
            'instance_group_name_2', 'ml.c5n.18xlarge', 64)]
    

    For instructions on how to use InstanceGroup objects to configure a heterogeneous cluster through the SageMaker generic and framework estimator classes, see Train Using a Heterogeneous Cluster in the Amazon SageMaker developer guide.

  • training_repository_access_mode (str) – Optional. Specifies how SageMaker accesses the Docker image that contains the training algorithm (default: None). Set this to one of the following values: * ‘Platform’ - The training image is hosted in Amazon ECR. * ‘Vpc’ - The training image is hosted in a private Docker registry in your VPC. When it’s default to None, its behavior will be same as ‘Platform’ - image is hosted in ECR.

  • training_repository_credentials_provider_arn (str) – Optional. The Amazon Resource Name (ARN) of an AWS Lambda function that provides credentials to authenticate to the private Docker registry where your training image is hosted (default: None). When it’s set to None, SageMaker will not do authentication before pulling the image in the private Docker registry.

  • container_entry_point (List[str]) – Optional. The entrypoint script for a Docker container used to run a training job. This script takes precedence over the default train processing instructions.

  • container_arguments (List[str]) – Optional. The arguments for a container used to run a training job.

  • disable_output_compression (bool) – Optional. When set to true, Model is uploaded to Amazon S3 without compression after training finishes.

  • enable_infra_check (bool or PipelineVariable) – Optional. Specifies whether it is running Sagemaker built-in infra check jobs.

  • enable_remote_debug (bool or PipelineVariable) – Optional. Specifies whether RemoteDebug is enabled for the training job.

  • enable_session_tag_chaining (bool or PipelineVariable) – Optional. Specifies whether SessionTagChaining is enabled for the training job.

LAUNCH_PT_XLA_ENV_NAME = 'sagemaker_pytorch_xla_multi_worker_enabled'
LAUNCH_PS_ENV_NAME = 'sagemaker_parameter_server_enabled'
LAUNCH_MPI_ENV_NAME = 'sagemaker_mpi_enabled'
LAUNCH_SM_DDP_ENV_NAME = 'sagemaker_distributed_dataparallel_enabled'
LAUNCH_MWMS_ENV_NAME = 'sagemaker_multi_worker_mirrored_strategy_enabled'
INSTANCE_TYPE = 'sagemaker_instance_type'
MPI_NUM_PROCESSES_PER_HOST = 'sagemaker_mpi_num_of_processes_per_host'
MPI_CUSTOM_MPI_OPTIONS = 'sagemaker_mpi_custom_mpi_options'
SM_DDP_CUSTOM_MPI_OPTIONS = 'sagemaker_distributed_dataparallel_custom_mpi_options'
CONTAINER_CODE_CHANNEL_SOURCEDIR_PATH = '/opt/ml/input/data/code/sourcedir.tar.gz'
JOB_CLASS_NAME = 'training-job'
abstract training_image_uri()

Return the Docker image to use for training.

The fit() method, which does the model training, calls this method to find the image to use for model training.

Returns

The URI of the Docker image.

Return type

str

abstract hyperparameters()

Return the hyperparameters as a dictionary to use for training.

The fit() method, which trains the model, calls this method to find the hyperparameters.

Returns

The hyperparameters.

Return type

dict[str, str]

enable_network_isolation()

Return True if this Estimator will need network isolation to run.

Returns

Whether this Estimator needs network isolation or not.

Return type

bool

prepare_workflow_for_training(job_name=None)

Calls _prepare_for_training. Used when setting up a workflow.

Parameters

job_name (str) – Name of the training job to be created. If not specified, one is generated, using the base name given to the constructor if applicable.

latest_job_debugger_artifacts_path()

Gets the path to the DebuggerHookConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_tensorboard_artifacts_path()

Gets the path to the TensorBoardOutputConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_profiler_artifacts_path()

Gets the path to the profiling output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

fit(inputs=None, wait=True, logs='All', job_name=None, experiment_config=None)

Train a model using the input training dataset.

The API calls the Amazon SageMaker CreateTrainingJob API to start model training. The API uses configuration you provided to create the estimator and the specified input training data to send the CreatingTrainingJob request to Amazon SageMaker.

This is a synchronous operation. After the model training successfully completes, you can call the deploy() method to host the model using the Amazon SageMaker hosting services.

Parameters
  • or (inputs (str or dict or sagemaker.inputs.TrainingInput) –

    sagemaker.inputs.FileSystemInput): Information about the training data. This can be one of four types:

    • (str) the S3 location where training data is saved, or a file:// path in

      local mode.

    • (dict[str, str] or dict[str, sagemaker.inputs.TrainingInput] or

      dict[str, sagemaker.inputs.FileSystemInput]) If using multiple channels for training data, you can specify a dict mapping channel names to strings or TrainingInput() objects or FileSystemInput() objects.

    • (sagemaker.inputs.TrainingInput) - channel configuration for S3 data sources

      that can provide additional information as well as the path to the training dataset. See sagemaker.inputs.TrainingInput() for full details.

    • (sagemaker.inputs.FileSystemInput) - channel configuration for

      a file system data source that can provide additional information as well as the path to the training dataset.

  • wait (bool) – Whether the call should wait until the job completes (default: True).

  • logs ([str]) – A list of strings specifying which logs to print. Acceptable strings are “All”, “None”, “Training”, or “Rules”. To maintain backwards compatibility, boolean values are also accepted and converted to strings. Only meaningful when wait is True.

  • job_name (str) – Training job name. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

  • experiment_config (dict[str, str]) – Experiment management configuration. Optionally, the dict can contain four keys: ‘ExperimentName’, ‘TrialName’, ‘TrialComponentDisplayName’ and ‘RunName’.. The behavior of setting these keys is as follows: * If ExperimentName is supplied but TrialName is not a Trial will be automatically created and the job’s Trial Component associated with the Trial. * If TrialName is supplied and the Trial already exists the job’s Trial Component will be associated with the Trial. * If both ExperimentName and TrialName are not supplied the trial component will be unassociated. * TrialComponentDisplayName is used for display in Studio. * Both ExperimentName and TrialName will be ignored if the Estimator instance is built with PipelineSession. However, the value of TrialComponentDisplayName is honored for display in Studio.

  • inputs (Optional[Union[str, Dict, TrainingInput, FileSystemInput]]) –

Returns

None or pipeline step arguments in case the Estimator instance is built with PipelineSession

compile_model(target_instance_family, input_shape, output_path, framework=None, framework_version=None, compile_max_run=900, tags=None, target_platform_os=None, target_platform_arch=None, target_platform_accelerator=None, compiler_options=None, **kwargs)

Compile a Neo model using the input model.

Parameters
Returns

A SageMaker Model object. See Model() for full details.

Return type

sagemaker.model.Model

classmethod attach(training_job_name, sagemaker_session=None, model_channel_name='model')

Attach to an existing training job.

Create an Estimator bound to an existing training job, each subclass is responsible to implement _prepare_init_params_from_job_description() as this method delegates the actual conversion of a training job description to the arguments that the class constructor expects. After attaching, if the training job has a Complete status, it can be deploy() ed to create a SageMaker Endpoint and return a Predictor.

If the training job is in progress, attach will block until the training job completes, but logs of the training job will not display. To see the logs content, please call logs()

Examples

>>> my_estimator.fit(wait=False)
>>> training_job_name = my_estimator.latest_training_job.name
Later on:
>>> attached_estimator = Estimator.attach(training_job_name)
>>> attached_estimator.logs()
>>> attached_estimator.deploy()
Parameters
  • training_job_name (str) – The name of the training job to attach to.

  • sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain.

  • model_channel_name (str) – Name of the channel where pre-trained model data will be downloaded (default: ‘model’). If no channel with the same name exists in the training job, this option will be ignored.

Returns

Instance of the calling Estimator Class with the attached training job.

logs()

Display the logs for Estimator’s training job.

If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

deploy(initial_instance_count=None, instance_type=None, serializer=None, deserializer=None, accelerator_type=None, endpoint_name=None, use_compiled_model=False, wait=True, model_name=None, kms_key=None, data_capture_config=None, tags=None, serverless_inference_config=None, async_inference_config=None, volume_size=None, model_data_download_timeout=None, container_startup_health_check_timeout=None, inference_recommendation_id=None, explainer_config=None, **kwargs)

Deploy the trained model to an Amazon SageMaker endpoint.

And then return sagemaker.Predictor object.

More information: http://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html

Parameters
  • initial_instance_count (int) – The initial number of instances to run in the Endpoint created from this Model. If not using serverless inference, then it need to be a number larger or equals to 1 (default: None)

  • instance_type (str) – The EC2 instance type to deploy this Model to. For example, ‘ml.p2.xlarge’, or ‘local’ for local mode. If not using serverless inference, then it is required to deploy a model. (default: None)

  • serializer (BaseSerializer) – A serializer object, used to encode data for an inference endpoint (default: None). If serializer is not None, then serializer will override the default serializer. The default serializer is set by the predictor_cls.

  • deserializer (BaseDeserializer) – A deserializer object, used to decode data from an inference endpoint (default: None). If deserializer is not None, then deserializer will override the default deserializer. The default deserializer is set by the predictor_cls.

  • accelerator_type (str) – Type of Elastic Inference accelerator to attach to an endpoint for model loading and inference, for example, ‘ml.eia1.medium’. If not specified, no Elastic Inference accelerator will be attached to the endpoint. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html

  • endpoint_name (str) – Name to use for creating an Amazon SageMaker endpoint. If not specified, the name of the training job is used.

  • use_compiled_model (bool) – Flag to select whether to use compiled (optimized) model. Default: False.

  • wait (bool) – Whether the call should wait until the deployment of model completes (default: True).

  • model_name (str) – Name to use for creating an Amazon SageMaker model. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

  • kms_key (str) – The ARN of the KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint.

  • data_capture_config (sagemaker.model_monitor.DataCaptureConfig) – Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.

  • async_inference_config (sagemaker.model_monitor.AsyncInferenceConfig) – Specifies configuration related to async inference. Use this configuration when trying to create async endpoint and make async inference. If empty config object passed through, will use default config to deploy async endpoint. Deploy a real-time endpoint if it’s None. (default: None)

  • serverless_inference_config (sagemaker.serverless.ServerlessInferenceConfig) – Specifies configuration related to serverless endpoint. Use this configuration when trying to create serverless endpoint and make serverless inference. If empty object passed through, will use pre-defined values in ServerlessInferenceConfig class to deploy serverless endpoint. Deploy an instance based endpoint if it’s None. (default: None)

  • tags (Optional[Tags]) – Optional. Tags to attach to this specific endpoint. Example: >>> tags = {‘tagname’, ‘tagvalue’} Or >>> tags = [{‘Key’: ‘tagname’, ‘Value’: ‘tagvalue’}] For more information about tags, see https://boto3.amazonaws.com/v1/documentation /api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags

  • volume_size (int) – The size, in GB, of the ML storage volume attached to individual inference instance associated with the production variant. Currenly only Amazon EBS gp2 storage volumes are supported.

  • model_data_download_timeout (int) – The timeout value, in seconds, to download and extract model data from Amazon S3 to the individual inference instance associated with this production variant.

  • container_startup_health_check_timeout (int) – The timeout value, in seconds, for your inference container to pass health check by SageMaker Hosting. For more information about health check see: https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-algo-ping-requests

  • inference_recommendation_id (str) – The recommendation id which specifies the recommendation you picked from inference recommendation job results and would like to deploy the model and endpoint with recommended parameters.

  • explainer_config (sagemaker.explainer.ExplainerConfig) – Specifies online explainability configuration for use with Amazon SageMaker Clarify. (default: None)

  • **kwargs – Passed to invocation of create_model(). Implementations may customize create_model() to accept **kwargs to customize model creation during deploy. For more, see the implementation docs.

Returns

A predictor that provides a predict() method,

which can be used to send requests to the Amazon SageMaker endpoint and obtain inferences.

Return type

sagemaker.predictor.Predictor

register(content_types=None, response_types=None, inference_instances=None, transform_instances=None, image_uri=None, model_package_name=None, model_package_group_name=None, model_metrics=None, metadata_properties=None, marketplace_cert=False, approval_status=None, description=None, compile_model_family=None, model_name=None, drift_check_baselines=None, customer_metadata_properties=None, domain=None, sample_payload_url=None, task=None, framework=None, framework_version=None, nearest_model_name=None, data_input_configuration=None, skip_model_validation=None, source_uri=None, model_card=None, **kwargs)

Creates a model package for creating SageMaker models or listing on Marketplace.

Parameters
  • content_types (list) – The supported MIME types for the input data.

  • response_types (list) – The supported MIME types for the output data.

  • inference_instances (list) – A list of the instance types that are used to generate inferences in real-time (default: None).

  • transform_instances (list) – A list of the instance types on which a transformation job can be run or on which an endpoint can be deployed (default: None).

  • image_uri (str) – The container image uri for Model Package, if not specified, Estimator’s training container image will be used (default: None).

  • model_package_name (str) – Model Package name, exclusive to model_package_group_name, using model_package_name makes the Model Package un-versioned (default: None).

  • model_package_group_name (str) – Model Package Group name, exclusive to model_package_name, using model_package_group_name makes the Model Package versioned (default: None).

  • model_metrics (ModelMetrics) – ModelMetrics object (default: None).

  • metadata_properties (MetadataProperties) – MetadataProperties (default: None).

  • marketplace_cert (bool) – A boolean value indicating if the Model Package is certified for AWS Marketplace (default: False).

  • approval_status (str) – Model Approval Status, values can be “Approved”, “Rejected”, or “PendingManualApproval” (default: “PendingManualApproval”).

  • description (str) – Model Package description (default: None).

  • compile_model_family (str) – Instance family for compiled model, if specified, a compiled model will be used (default: None).

  • model_name (str) – User defined model name (default: None).

  • drift_check_baselines (DriftCheckBaselines) – DriftCheckBaselines object (default: None).

  • customer_metadata_properties (dict[str, str]) – A dictionary of key-value paired metadata properties (default: None).

  • domain (str) – Domain values can be “COMPUTER_VISION”, “NATURAL_LANGUAGE_PROCESSING”, “MACHINE_LEARNING” (default: None).

  • sample_payload_url (str) – The S3 path where the sample payload is stored (default: None).

  • task (str) – Task values which are supported by Inference Recommender are “FILL_MASK”, “IMAGE_CLASSIFICATION”, “OBJECT_DETECTION”, “TEXT_GENERATION”, “IMAGE_SEGMENTATION”, “CLASSIFICATION”, “REGRESSION”, “OTHER” (default: None).

  • framework (str) – Machine learning framework of the model package container image (default: None).

  • framework_version (str) – Framework version of the Model Package Container Image (default: None).

  • nearest_model_name (str) – Name of a pre-trained machine learning benchmarked by Amazon SageMaker Inference Recommender (default: None).

  • data_input_configuration (str) – Input object for the model (default: None).

  • skip_model_validation (str) – Indicates if you want to skip model validation. Values can be “All” or “None” (default: None).

  • source_uri (str) – The URI of the source for the model package (default: None).

  • model_card (ModeCard or ModelPackageModelCard) – document contains qualitative and quantitative information about a model (default: None).

  • **kwargs – Passed to invocation of create_model(). Implementations may customize create_model() to accept **kwargs to customize model creation during deploy. For more, see the implementation docs.

Returns

A string of SageMaker Model Package ARN.

Return type

str

property model_data

The model location in S3. Only set if Estimator has been fit().

Type

Str or dict

abstract create_model(**kwargs)

Create a SageMaker Model object that can be deployed to an Endpoint.

Parameters

**kwargs – Keyword arguments used by the implemented method for creating the Model.

Returns

A SageMaker Model object. See Model() for full details.

Return type

sagemaker.model.Model

transformer(instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, env=None, max_concurrent_transforms=None, max_payload=None, tags=None, role=None, volume_kms_key=None, vpc_config_override='VPC_CONFIG_DEFAULT', enable_network_isolation=None, model_name=None)

Return a Transformer that uses a SageMaker Model based on the training job.

It reuses the SageMaker Session and base job name used by the Estimator.

Parameters
  • instance_count (int) – Number of EC2 instances to use.

  • instance_type (str) – Type of EC2 instance to use, for example, ‘ml.c4.xlarge’.

  • strategy (str) – The strategy used to decide how to batch records in a single request (default: None). Valid values: ‘MultiRecord’ and ‘SingleRecord’.

  • assemble_with (str) – How the output is assembled (default: None). Valid values: ‘Line’ or ‘None’.

  • output_path (str) – S3 location for saving the transform result. If not specified, results are stored to a default bucket.

  • output_kms_key (str) – Optional. KMS key ID for encrypting the transform output (default: None).

  • accept (str) – The accept header passed by the client to the inference endpoint. If it is supported by the endpoint, it will be the format of the batch transform output.

  • env (dict) – Environment variables to be set for use during the transform job (default: None).

  • max_concurrent_transforms (int) – The maximum number of HTTP requests to be made to each individual transform container at one time.

  • max_payload (int) – Maximum size of the payload in a single HTTP request to the container in MB.

  • tags (Optional[Tags]) – Tags for labeling a transform job. If none specified, then the tags used for the training job are used for the transform job.

  • role (str) – The ExecutionRoleArn IAM Role ARN for the Model, which is also used during transform jobs. If not specified, the role from the Estimator will be used.

  • volume_kms_key (str) – Optional. KMS key ID for encrypting the volume attached to the ML compute instance (default: None).

  • vpc_config_override (dict[str, list[str]]) –

    Optional override for the VpcConfig set on the model. Default: use subnets and security groups from this Estimator.

    • ’Subnets’ (list[str]): List of subnet ids.

    • ’SecurityGroupIds’ (list[str]): List of security group ids.

  • enable_network_isolation (bool) – Specifies whether container will run in network isolation mode. Network isolation mode restricts the container access to outside networks (such as the internet). The container does not make any inbound or outbound network calls. If True, a channel named “code” will be created for any user entry script for inference. Also known as Internet-free mode. If not specified, this setting is taken from the estimator’s current configuration.

  • model_name (str) – Name to use for creating an Amazon SageMaker model. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

property training_job_analytics

Return a TrainingJobAnalytics object for the current training job.

get_vpc_config(vpc_config_override='VPC_CONFIG_DEFAULT')

Returns VpcConfig dict either from this Estimator’s subnets and security groups.

Or else validate and return an optional override value.

Parameters

vpc_config_override

delete_endpoint(**kwargs)
enable_default_profiling()

Update training job to enable Debugger monitoring.

This method enables Debugger monitoring with the default profiler_config parameter to collect system metrics and the default built-in profiler_report rule. Framework metrics won’t be saved. To update training job to emit framework metrics, you can use update_profiler method and specify the framework metrics you want to enable.

This method is callable when the training job is in progress while Debugger monitoring is disabled.

disable_profiling()

Update the current training job in progress to disable profiling.

Debugger stops collecting the system and framework metrics and turns off the Debugger built-in monitoring and profiling rules.

update_profiler(rules=None, system_monitor_interval_millis=None, s3_output_path=None, framework_profile_params=None, disable_framework_metrics=False)

Update training jobs to enable profiling.

This method updates the profiler_config parameter and initiates Debugger built-in rules for profiling.

Parameters
  • rules (list[ProfilerRule]) – A list of ProfilerRule objects to define rules for continuous analysis with SageMaker Debugger. Currently, you can only add new profiler rules during the training job. (default: None)

  • s3_output_path (str) – The location in S3 to store the output. If profiler is enabled once, s3_output_path cannot be changed. (default: None)

  • system_monitor_interval_millis (int) – How often profiling system metrics are collected; Unit: Milliseconds (default: None)

  • framework_profile_params (FrameworkProfile) – A parameter object for framework metrics profiling. Configure it using the FrameworkProfile class. To use the default framework profile parameters, pass FrameworkProfile(). For more information about the default values, see FrameworkProfile. (default: None)

  • disable_framework_metrics (bool) – Specify whether to disable all the framework metrics. This won’t update system metrics and the Debugger built-in rules for monitoring. To stop both monitoring and profiling, use the desable_profiling method. (default: False)

Attention

Updating the profiling configuration for TensorFlow dataloader profiling is currently not available. If you started a TensorFlow training job only with monitoring and want to enable profiling while the training job is running, the dataloader profiling cannot be updated.

get_remote_debug_config()

dict: Return the configuration of RemoteDebug

get_session_chaining_config()

dict: Return the configuration of SessionChaining

enable_remote_debug()

Enable remote debug for a training job.

disable_remote_debug()

Disable remote debug for a training job.

get_app_url(app_type, open_in_default_web_browser=True, create_presigned_domain_url=False, domain_id=None, user_profile_name=None, optional_create_presigned_url_kwargs=None)

Generate a URL to help access the specified app hosted in Amazon SageMaker Studio.

Parameters
  • app_type (str or SupportedInteractiveAppTypes) – Required. The app type available in SageMaker Studio to return a URL to.

  • open_in_default_web_browser (bool) – Optional. When True, the URL will attempt to be opened in the environment’s default web browser. Otherwise, the resulting URL will be returned by this function. Default: True

  • create_presigned_domain_url (bool) – Optional. Determines whether a presigned domain URL should be generated instead of an unsigned URL. This only applies when called from outside of a SageMaker Studio environment. If this is set to True inside of a SageMaker Studio environment, it will be ignored. Default: False

  • domain_id (str) – Optional. The AWS Studio domain that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • user_profile_name (str) – Optional. The AWS Studio user profile that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • optional_create_presigned_url_kwargs (dict) – Optional. This parameter should be passed when a user outside of Studio wants a presigned URL to the TensorBoard application and wants to modify the optional parameters of the create_presigned_domain_url call. Default: None

Returns

A URL for the requested app in SageMaker Studio.

Return type

str

class sagemaker.estimator.Estimator(image_uri, role=None, instance_count=None, instance_type=None, keep_alive_period_in_seconds=None, volume_size=30, volume_kms_key=None, max_run=86400, input_mode='File', output_path=None, output_kms_key=None, base_job_name=None, sagemaker_session=None, hyperparameters=None, tags=None, subnets=None, security_group_ids=None, model_uri=None, model_channel_name='model', metric_definitions=None, encrypt_inter_container_traffic=None, use_spot_instances=False, max_wait=None, checkpoint_s3_uri=None, checkpoint_local_path=None, enable_network_isolation=None, rules=None, debugger_hook_config=None, tensorboard_output_config=None, enable_sagemaker_metrics=None, profiler_config=None, disable_profiler=False, environment=None, max_retry_attempts=None, source_dir=None, git_config=None, container_log_level=20, code_location=None, entry_point=None, dependencies=None, instance_groups=None, training_repository_access_mode=None, training_repository_credentials_provider_arn=None, container_entry_point=None, container_arguments=None, disable_output_compression=False, enable_infra_check=None, enable_remote_debug=None, enable_session_tag_chaining=None, **kwargs)

Bases: EstimatorBase

A generic Estimator to train using any supplied algorithm.

This class is designed for use with algorithms that don’t have their own, custom class.

Initialize an Estimator instance.

Parameters
  • image_uri (str or PipelineVariable) – The container image to use for training.

  • role (str) – An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. After the endpoint is created, the inference code might use the IAM role, if it needs to access an AWS resource.

  • instance_count (int or PipelineVariable) – Number of Amazon EC2 instances to use for training. Required if instance_groups is not set.

  • instance_type (str or PipelineVariable) – Type of EC2 instance to use for training, for example, 'ml.c4.xlarge'. Required if instance_groups is not set.

  • keep_alive_period_in_seconds (int) – The duration of time in seconds to retain configured resources in a warm pool for subsequent training jobs (default: None).

  • volume_size (int or PipelineVariable) –

    Size in GB of the storage volume to use for storing input and output data during training (default: 30).

    Must be large enough to store training data if File mode is used, which is the default mode.

    When you use an ML instance with the EBS-only storage option such as ml.c5 and ml.p2, you must define the size of the EBS volume through the volume_size parameter in the estimator class.

    Note

    When you use an ML instance with NVMe SSD volumes such as ml.p4d, ml.g4dn, and ml.g5, do not include this parameter in the estimator configuration. If you use one of those ML instance types, SageMaker doesn’t provision Amazon EBS General Purpose SSD (gp2) storage nor take this parameter to adjust the NVMe instance storage. Available storage is fixed to the NVMe instance storage capacity. SageMaker configures storage paths for training datasets, checkpoints, model artifacts, and outputs to use the entire capacity of the instance storage.

    Note that if you include this parameter and specify a number that exceeds the size of the NVMe volume attached to the instance type, SageMaker returns an Invalid VolumeSizeInGB error.

    To look up instance types and their instance storage types and volumes, see Amazon EC2 Instance Types.

    To find the default local paths defined by the SageMaker training platform, see Amazon SageMaker Training Storage Folders for Training Datasets, Checkpoints, Model Artifacts, and Outputs.

  • volume_kms_key (str or PipelineVariable) – Optional. KMS key ID for encrypting EBS volume attached to the training instance (default: None).

  • max_run (int or PipelineVariable) – Timeout in seconds for training (default: 24 * 60 * 60). After this amount of time Amazon SageMaker terminates the job regardless of its current status.

  • input_mode (str or PipelineVariable) –

    The input mode that the algorithm supports (default: ‘File’). Valid modes:

    • ’File’ - Amazon SageMaker copies the training dataset from the S3 location to a local directory.

    • ’Pipe’ - Amazon SageMaker streams data directly from S3 to the container via a Unix-named pipe.

    This argument can be overriden on a per-channel basis using sagemaker.inputs.TrainingInput.input_mode.

  • output_path (str or PipelineVariable) – S3 location for saving the training result (model artifacts and output files). If not specified, results are stored to a default bucket. If the bucket with the specific name does not exist, the estimator creates the bucket during the fit() method execution.

  • output_kms_key (str or PipelineVariable) – Optional. KMS key ID for encrypting the training output (default: None).

  • base_job_name (str) – Prefix for training job name when the fit() method launches. If not specified, the estimator generates a default job name, based on the training image name and current timestamp.

  • sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain.

  • hyperparameters (dict[str, str] or dict[str, PipelineVariable]) –

    Dictionary containing the hyperparameters to initialize this estimator with.

    Caution

    You must not include any security-sensitive information, such as account access IDs, secrets, and tokens, in the dictionary for configuring hyperparameters. SageMaker rejects the training job request and returns an validation error for detected credentials, if such user input is found.

  • tags (Optional[Tags]) – Tags for labeling a training job. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html.

  • subnets (list[str] or list[PipelineVariable]) – List of subnet ids. If not specified training job will be created without VPC config.

  • security_group_ids (list[str] or list[PipelineVariable]) – List of security group ids. If not specified training job will be created without VPC config.

  • model_uri (str) –

    URI where a pre-trained model is stored, either locally or in S3 (default: None). If specified, the estimator will create a channel pointing to the model so the training job can download it. This model can be a ‘model.tar.gz’ from a previous training job, or other artifacts coming from a different source.

    In local mode, this should point to the path in which the model is located and not the file itself, as local Docker containers will try to mount the URI as a volume.

    More information: https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html#td-deserialization

  • model_channel_name (str or PipelineVariable) – Name of the channel where ‘model_uri’ will be downloaded (default: ‘model’).

  • metric_definitions (list[dict[str, str] or list[dict[str, PipelineVariable]]) – A list of dictionaries that defines the metric(s) used to evaluate the training jobs. Each dictionary contains two keys: ‘Name’ for the name of the metric, and ‘Regex’ for the regular expression used to extract the metric from the logs. This should be defined only for jobs that don’t use an Amazon algorithm.

  • encrypt_inter_container_traffic (bool or PipelineVariable) – Specifies whether traffic between training containers is encrypted for the training job (default: False).

  • use_spot_instances (bool or PipelineVariable) –

    Specifies whether to use SageMaker Managed Spot instances for training. If enabled then the max_wait arg should also be set.

    More information: https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html (default: False).

  • max_wait (int or PipelineVariable) – Timeout in seconds waiting for spot training job (default: None). After this amount of time Amazon SageMaker will stop waiting for managed spot training job to complete (default: None).

  • checkpoint_s3_uri (str or PipelineVariable) – The S3 URI in which to persist checkpoints that the algorithm persists (if any) during training. (default: None).

  • checkpoint_local_path (str or PipelineVariable) – The local path that the algorithm writes its checkpoints to. SageMaker will persist all files under this path to checkpoint_s3_uri continually during training. On job startup the reverse happens - data from the s3 location is downloaded to this path before the algorithm is started. If the path is unset then SageMaker assumes the checkpoints will be provided under /opt/ml/checkpoints/. (default: None).

  • enable_network_isolation (bool or PipelineVariable) – Specifies whether container will run in network isolation mode (default: False). Network isolation mode restricts the container access to outside networks (such as the Internet). The container does not make any inbound or outbound network calls. Also known as Internet-free mode.

  • rules (list[RuleBase]) –

    A list of RuleBase objects used to define SageMaker Debugger rules for real-time analysis (default: None). For more information, see Continuous analyses through rules.

  • debugger_hook_config (DebuggerHookConfig or bool) –

    Configuration for how debugging information is emitted with SageMaker Debugger. If not specified, a default one is created using the estimator’s output_path, unless the region does not support SageMaker Debugger. To disable SageMaker Debugger, set this parameter to False. For more information, see Capture real-time debugging data during model training in Amazon SageMaker.

  • tensorboard_output_config (TensorBoardOutputConfig) –

    Configuration for customizing debugging visualization using TensorBoard (default: None). For more information, see Capture real time tensorboard data.

  • enable_sagemaker_metrics (bool or PipelineVariable) –

    enable SageMaker Metrics Time Series. For more information, see AlgorithmSpecification API. (default: None).

  • profiler_config (ProfilerConfig) – Configuration for how SageMaker Debugger collects monitoring and profiling information from your training job. If not specified, Debugger will be configured with a default configuration and will save system and framework metrics the estimator’s default output_path in Amazon S3. Use ProfilerConfig to configure this parameter. To disable SageMaker Debugger monitoring and profiling, set the disable_profiler parameter to True.

  • disable_profiler (bool) – Specifies whether Debugger monitoring and profiling will be disabled (default: False).

  • environment (dict[str, str] or dict[str, PipelineVariable]) – Environment variables to be set for use during training job (default: None)

  • max_retry_attempts (int or PipelineVariable) – The number of times to move a job to the STARTING status. You can specify between 1 and 30 attempts. If the value of attempts is greater than zero, the job is retried on InternalServerFailure the same number of attempts as the value. You can cap the total duration for your job by setting max_wait and max_run (default: None)

  • source_dir (str or PipelineVariable) –

    The absolute, relative, or S3 URI Path to a directory with any other training source code dependencies aside from the entry point file (default: None). If source_dir is an S3 URI, it must point to a tar.gz file. Structure within this directory is preserved when training on Amazon SageMaker. If ‘git_config’ is provided, ‘source_dir’ should be a relative location to a directory in the Git repo.

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- train.py
    >>>         |----- test.py
    

    if you need ‘train.py’ as the entry point and ‘test.py’ as the training source code, you can assign entry_point=’train.py’, source_dir=’src’.

  • git_config (dict[str, str]) –

    Git configurations used for cloning files, including repo, branch, commit, 2FA_enabled, username, password and token. The repo field is required. All other fields are optional. repo specifies the Git repository where your training script is stored. If you don’t provide branch, the default value ‘master’ is used. If you don’t provide commit, the latest commit in the specified branch is used.

    Example

    The following config:

    >>> git_config = {'repo': 'https://github.com/aws/sagemaker-python-sdk.git',
    >>>               'branch': 'test-branch-git-config',
    >>>               'commit': '329bfcf884482002c05ff7f44f62599ebc9f445a'}
    

    results in cloning the repo specified in ‘repo’, then checking out the ‘master’ branch, and checking out the specified commit.

    2FA_enabled, username, password and token are used for authentication. For GitHub (or other Git) accounts, set 2FA_enabled to ‘True’ if two-factor authentication is enabled for the account, otherwise set it to ‘False’. If you do not provide a value for 2FA_enabled, a default value of ‘False’ is used. CodeCommit does not support two-factor authentication, so do not provide “2FA_enabled” with CodeCommit repositories.

    For GitHub and other Git repos, when SSH URLs are provided, it doesn’t matter whether 2FA is enabled or disabled. You should either have no passphrase for the SSH key pairs or have the ssh-agent configured so that you will not be prompted for the SSH passphrase when you run the ‘git clone’ command with SSH URLs. When HTTPS URLs are provided, if 2FA is disabled, then either token or username and password are be used for authentication if provided. Token is prioritized. If 2FA is enabled, only token is used for authentication if provided. If required authentication info is not provided, the SageMaker Python SDK attempts to use local credentials to authenticate. If that fails, an error message is thrown.

    For CodeCommit repos, 2FA is not supported, so 2FA_enabled should not be provided. There is no token in CodeCommit, so token should also not be provided. When repo is an SSH URL, the requirements are the same as GitHub repos. When repo is an HTTPS URL, username and password are used for authentication if they are provided. If they are not provided, the SageMaker Python SDK attempts to use either the CodeCommit credential helper or local credential storage for authentication.

  • container_log_level (int or PipelineVariable) – The log level to use within the container (default: logging.INFO). Valid values are defined in the Python logging module.

  • code_location (str) – The S3 prefix URI where custom code is uploaded (default: None). You must not include a trailing slash because a string prepended with a “/” is appended to code_location. The code file uploaded to S3 is ‘code_location/job-name/source/sourcedir.tar.gz’. If not specified, the default code location is ‘s3://output_bucket/job-name/’.

  • entry_point (str or PipelineVariable) –

    The absolute or relative path to the local Python source file that should be executed as the entry point to training. If source_dir is specified, then entry_point must point to a file located at the root of source_dir. If ‘git_config’ is provided, ‘entry_point’ should be a relative location to the Python source file in the Git repo.

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- train.py
    >>>         |----- test.py
    

    You can assign entry_point=’src/train.py’.

  • dependencies (list[str]) –

    A list of absolute or relative paths to directories with any additional libraries that should be exported to the container (default: []). The library folders are copied to SageMaker in the same folder where the entrypoint is copied. If ‘git_config’ is provided, ‘dependencies’ should be a list of relative locations to directories with any additional libraries needed in the Git repo.

    Example

    The following Estimator call:

    >>> Estimator(entry_point='train.py',
    ...           dependencies=['my/libs/common', 'virtual-env'])
    

    results in the following structure inside the container:

    >>> $ ls
    
    >>> opt/ml/code
    >>>     |------ train.py
    >>>     |------ common
    >>>     |------ virtual-env
    

    This is not supported with “local code” in Local Mode.

  • instance_groups (list[sagemaker.instance_group.InstanceGroup]) –

    Optional. A list of InstanceGroup objects for launching a training job with a heterogeneous cluster. For example:

    instance_groups=[
        sagemaker.InstanceGroup(
            'instance_group_name_1', 'ml.p3dn.24xlarge', 64),
        sagemaker.InstanceGroup(
            'instance_group_name_2', 'ml.c5n.18xlarge', 64)]
    

    For instructions on how to use InstanceGroup objects to configure a heterogeneous cluster through the SageMaker generic and framework estimator classes, see Train Using a Heterogeneous Cluster in the Amazon SageMaker developer guide.

  • training_repository_access_mode (str) – Optional. Specifies how SageMaker accesses the Docker image that contains the training algorithm (default: None). Set this to one of the following values: * ‘Platform’ - The training image is hosted in Amazon ECR. * ‘Vpc’ - The training image is hosted in a private Docker registry in your VPC. When it’s default to None, its behavior will be same as ‘Platform’ - image is hosted in ECR.

  • training_repository_credentials_provider_arn (str) – Optional. The Amazon Resource Name (ARN) of an AWS Lambda function that provides credentials to authenticate to the private Docker registry where your training image is hosted (default: None). When it’s set to None, SageMaker will not do authentication before pulling the image in the private Docker registry.

  • container_entry_point (List[str]) – Optional. The entrypoint script for a Docker container used to run a training job. This script takes precedence over the default train processing instructions.

  • container_arguments (List[str]) – Optional. The arguments for a container used to run a training job.

  • disable_output_compression (bool) – Optional. When set to true, Model is uploaded to Amazon S3 without compression after training finishes.

  • enable_infra_check (bool or PipelineVariable) – Optional. Specifies whether it is running Sagemaker built-in infra check jobs.

  • enable_remote_debug (bool or PipelineVariable) – Optional. Specifies whether RemoteDebug is enabled for the training job

  • enable_session_tag_chaining (bool or PipelineVariable) – Optional. Specifies whether SessionTagChaining is enabled for the training job

training_image_uri()

Returns the docker image to use for training.

The fit() method, that does the model training, calls this method to find the image to use for model training.

set_hyperparameters(**kwargs)

Sets the hyperparameter dictionary to use for training.

The hyperparameters are made accessible as a dict[str, str] to the training code on SageMaker. For convenience, this accepts other types for keys and values, but str() will be called to convert them before training.

If a source directory is specified, this method escapes the dict argument as JSON, and updates the private hyperparameter attribute.

hyperparameters()

Returns the hyperparameters as a dictionary to use for training.

The fit() method, that does the model training, calls this method to find the hyperparameters you specified.

create_model(role=None, image_uri=None, predictor_cls=None, vpc_config_override='VPC_CONFIG_DEFAULT', **kwargs)

Create a model to deploy.

The serializer and deserializer arguments are only used to define a default Predictor. They are ignored if an explicit predictor class is passed in. Other arguments are passed through to the Model class.

Parameters
  • role (str) – The ExecutionRoleArn IAM Role ARN for the Model, which is also used during transform jobs. If not specified, the role from the Estimator will be used.

  • image_uri (str) – A Docker image URI to use for deploying the model. Defaults to the image used for training.

  • predictor_cls (Predictor) – The predictor class to use when deploying the model.

  • vpc_config_override (dict[str, list[str]]) – Optional override for VpcConfig set on the model. Default: use subnets and security groups from this Estimator. * ‘Subnets’ (list[str]): List of subnet ids. * ‘SecurityGroupIds’ (list[str]): List of security group ids.

  • **kwargs – Additional parameters passed to Model

Tip

You can find additional parameters for using this method at Model.

Returns

(sagemaker.model.Model) a Model ready for deployment.

CONTAINER_CODE_CHANNEL_SOURCEDIR_PATH = '/opt/ml/input/data/code/sourcedir.tar.gz'
INSTANCE_TYPE = 'sagemaker_instance_type'
JOB_CLASS_NAME = 'training-job'
LAUNCH_MPI_ENV_NAME = 'sagemaker_mpi_enabled'
LAUNCH_MWMS_ENV_NAME = 'sagemaker_multi_worker_mirrored_strategy_enabled'
LAUNCH_PS_ENV_NAME = 'sagemaker_parameter_server_enabled'
LAUNCH_PT_XLA_ENV_NAME = 'sagemaker_pytorch_xla_multi_worker_enabled'
LAUNCH_SM_DDP_ENV_NAME = 'sagemaker_distributed_dataparallel_enabled'
MPI_CUSTOM_MPI_OPTIONS = 'sagemaker_mpi_custom_mpi_options'
MPI_NUM_PROCESSES_PER_HOST = 'sagemaker_mpi_num_of_processes_per_host'
SM_DDP_CUSTOM_MPI_OPTIONS = 'sagemaker_distributed_dataparallel_custom_mpi_options'
classmethod attach(training_job_name, sagemaker_session=None, model_channel_name='model')

Attach to an existing training job.

Create an Estimator bound to an existing training job, each subclass is responsible to implement _prepare_init_params_from_job_description() as this method delegates the actual conversion of a training job description to the arguments that the class constructor expects. After attaching, if the training job has a Complete status, it can be deploy() ed to create a SageMaker Endpoint and return a Predictor.

If the training job is in progress, attach will block until the training job completes, but logs of the training job will not display. To see the logs content, please call logs()

Examples

>>> my_estimator.fit(wait=False)
>>> training_job_name = my_estimator.latest_training_job.name
Later on:
>>> attached_estimator = Estimator.attach(training_job_name)
>>> attached_estimator.logs()
>>> attached_estimator.deploy()
Parameters
  • training_job_name (str) – The name of the training job to attach to.

  • sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain.

  • model_channel_name (str) – Name of the channel where pre-trained model data will be downloaded (default: ‘model’). If no channel with the same name exists in the training job, this option will be ignored.

Returns

Instance of the calling Estimator Class with the attached training job.

compile_model(target_instance_family, input_shape, output_path, framework=None, framework_version=None, compile_max_run=900, tags=None, target_platform_os=None, target_platform_arch=None, target_platform_accelerator=None, compiler_options=None, **kwargs)

Compile a Neo model using the input model.

Parameters
Returns

A SageMaker Model object. See Model() for full details.

Return type

sagemaker.model.Model

delete_endpoint(**kwargs)
deploy(initial_instance_count=None, instance_type=None, serializer=None, deserializer=None, accelerator_type=None, endpoint_name=None, use_compiled_model=False, wait=True, model_name=None, kms_key=None, data_capture_config=None, tags=None, serverless_inference_config=None, async_inference_config=None, volume_size=None, model_data_download_timeout=None, container_startup_health_check_timeout=None, inference_recommendation_id=None, explainer_config=None, **kwargs)

Deploy the trained model to an Amazon SageMaker endpoint.

And then return sagemaker.Predictor object.

More information: http://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html

Parameters
  • initial_instance_count (int) – The initial number of instances to run in the Endpoint created from this Model. If not using serverless inference, then it need to be a number larger or equals to 1 (default: None)

  • instance_type (str) – The EC2 instance type to deploy this Model to. For example, ‘ml.p2.xlarge’, or ‘local’ for local mode. If not using serverless inference, then it is required to deploy a model. (default: None)

  • serializer (BaseSerializer) – A serializer object, used to encode data for an inference endpoint (default: None). If serializer is not None, then serializer will override the default serializer. The default serializer is set by the predictor_cls.

  • deserializer (BaseDeserializer) – A deserializer object, used to decode data from an inference endpoint (default: None). If deserializer is not None, then deserializer will override the default deserializer. The default deserializer is set by the predictor_cls.

  • accelerator_type (str) – Type of Elastic Inference accelerator to attach to an endpoint for model loading and inference, for example, ‘ml.eia1.medium’. If not specified, no Elastic Inference accelerator will be attached to the endpoint. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html

  • endpoint_name (str) – Name to use for creating an Amazon SageMaker endpoint. If not specified, the name of the training job is used.

  • use_compiled_model (bool) – Flag to select whether to use compiled (optimized) model. Default: False.

  • wait (bool) – Whether the call should wait until the deployment of model completes (default: True).

  • model_name (str) – Name to use for creating an Amazon SageMaker model. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

  • kms_key (str) – The ARN of the KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint.

  • data_capture_config (sagemaker.model_monitor.DataCaptureConfig) – Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.

  • async_inference_config (sagemaker.model_monitor.AsyncInferenceConfig) – Specifies configuration related to async inference. Use this configuration when trying to create async endpoint and make async inference. If empty config object passed through, will use default config to deploy async endpoint. Deploy a real-time endpoint if it’s None. (default: None)

  • serverless_inference_config (sagemaker.serverless.ServerlessInferenceConfig) – Specifies configuration related to serverless endpoint. Use this configuration when trying to create serverless endpoint and make serverless inference. If empty object passed through, will use pre-defined values in ServerlessInferenceConfig class to deploy serverless endpoint. Deploy an instance based endpoint if it’s None. (default: None)

  • tags (Optional[Tags]) – Optional. Tags to attach to this specific endpoint. Example: >>> tags = {‘tagname’, ‘tagvalue’} Or >>> tags = [{‘Key’: ‘tagname’, ‘Value’: ‘tagvalue’}] For more information about tags, see https://boto3.amazonaws.com/v1/documentation /api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags

  • volume_size (int) – The size, in GB, of the ML storage volume attached to individual inference instance associated with the production variant. Currenly only Amazon EBS gp2 storage volumes are supported.

  • model_data_download_timeout (int) – The timeout value, in seconds, to download and extract model data from Amazon S3 to the individual inference instance associated with this production variant.

  • container_startup_health_check_timeout (int) – The timeout value, in seconds, for your inference container to pass health check by SageMaker Hosting. For more information about health check see: https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-algo-ping-requests

  • inference_recommendation_id (str) – The recommendation id which specifies the recommendation you picked from inference recommendation job results and would like to deploy the model and endpoint with recommended parameters.

  • explainer_config (sagemaker.explainer.ExplainerConfig) – Specifies online explainability configuration for use with Amazon SageMaker Clarify. (default: None)

  • **kwargs – Passed to invocation of create_model(). Implementations may customize create_model() to accept **kwargs to customize model creation during deploy. For more, see the implementation docs.

Returns

A predictor that provides a predict() method,

which can be used to send requests to the Amazon SageMaker endpoint and obtain inferences.

Return type

sagemaker.predictor.Predictor

disable_profiling()

Update the current training job in progress to disable profiling.

Debugger stops collecting the system and framework metrics and turns off the Debugger built-in monitoring and profiling rules.

disable_remote_debug()

Disable remote debug for a training job.

enable_default_profiling()

Update training job to enable Debugger monitoring.

This method enables Debugger monitoring with the default profiler_config parameter to collect system metrics and the default built-in profiler_report rule. Framework metrics won’t be saved. To update training job to emit framework metrics, you can use update_profiler method and specify the framework metrics you want to enable.

This method is callable when the training job is in progress while Debugger monitoring is disabled.

enable_network_isolation()

Return True if this Estimator will need network isolation to run.

Returns

Whether this Estimator needs network isolation or not.

Return type

bool

enable_remote_debug()

Enable remote debug for a training job.

fit(inputs=None, wait=True, logs='All', job_name=None, experiment_config=None)

Train a model using the input training dataset.

The API calls the Amazon SageMaker CreateTrainingJob API to start model training. The API uses configuration you provided to create the estimator and the specified input training data to send the CreatingTrainingJob request to Amazon SageMaker.

This is a synchronous operation. After the model training successfully completes, you can call the deploy() method to host the model using the Amazon SageMaker hosting services.

Parameters
  • or (inputs (str or dict or sagemaker.inputs.TrainingInput) –

    sagemaker.inputs.FileSystemInput): Information about the training data. This can be one of four types:

    • (str) the S3 location where training data is saved, or a file:// path in

      local mode.

    • (dict[str, str] or dict[str, sagemaker.inputs.TrainingInput] or

      dict[str, sagemaker.inputs.FileSystemInput]) If using multiple channels for training data, you can specify a dict mapping channel names to strings or TrainingInput() objects or FileSystemInput() objects.

    • (sagemaker.inputs.TrainingInput) - channel configuration for S3 data sources

      that can provide additional information as well as the path to the training dataset. See sagemaker.inputs.TrainingInput() for full details.

    • (sagemaker.inputs.FileSystemInput) - channel configuration for

      a file system data source that can provide additional information as well as the path to the training dataset.

  • wait (bool) – Whether the call should wait until the job completes (default: True).

  • logs ([str]) – A list of strings specifying which logs to print. Acceptable strings are “All”, “None”, “Training”, or “Rules”. To maintain backwards compatibility, boolean values are also accepted and converted to strings. Only meaningful when wait is True.

  • job_name (str) – Training job name. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

  • experiment_config (dict[str, str]) – Experiment management configuration. Optionally, the dict can contain four keys: ‘ExperimentName’, ‘TrialName’, ‘TrialComponentDisplayName’ and ‘RunName’.. The behavior of setting these keys is as follows: * If ExperimentName is supplied but TrialName is not a Trial will be automatically created and the job’s Trial Component associated with the Trial. * If TrialName is supplied and the Trial already exists the job’s Trial Component will be associated with the Trial. * If both ExperimentName and TrialName are not supplied the trial component will be unassociated. * TrialComponentDisplayName is used for display in Studio. * Both ExperimentName and TrialName will be ignored if the Estimator instance is built with PipelineSession. However, the value of TrialComponentDisplayName is honored for display in Studio.

  • inputs (Optional[Union[str, Dict, TrainingInput, FileSystemInput]]) –

Returns

None or pipeline step arguments in case the Estimator instance is built with PipelineSession

get_app_url(app_type, open_in_default_web_browser=True, create_presigned_domain_url=False, domain_id=None, user_profile_name=None, optional_create_presigned_url_kwargs=None)

Generate a URL to help access the specified app hosted in Amazon SageMaker Studio.

Parameters
  • app_type (str or SupportedInteractiveAppTypes) – Required. The app type available in SageMaker Studio to return a URL to.

  • open_in_default_web_browser (bool) – Optional. When True, the URL will attempt to be opened in the environment’s default web browser. Otherwise, the resulting URL will be returned by this function. Default: True

  • create_presigned_domain_url (bool) – Optional. Determines whether a presigned domain URL should be generated instead of an unsigned URL. This only applies when called from outside of a SageMaker Studio environment. If this is set to True inside of a SageMaker Studio environment, it will be ignored. Default: False

  • domain_id (str) – Optional. The AWS Studio domain that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • user_profile_name (str) – Optional. The AWS Studio user profile that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • optional_create_presigned_url_kwargs (dict) – Optional. This parameter should be passed when a user outside of Studio wants a presigned URL to the TensorBoard application and wants to modify the optional parameters of the create_presigned_domain_url call. Default: None

Returns

A URL for the requested app in SageMaker Studio.

Return type

str

get_remote_debug_config()

dict: Return the configuration of RemoteDebug

get_session_chaining_config()

dict: Return the configuration of SessionChaining

get_vpc_config(vpc_config_override='VPC_CONFIG_DEFAULT')

Returns VpcConfig dict either from this Estimator’s subnets and security groups.

Or else validate and return an optional override value.

Parameters

vpc_config_override

latest_job_debugger_artifacts_path()

Gets the path to the DebuggerHookConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_profiler_artifacts_path()

Gets the path to the profiling output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_tensorboard_artifacts_path()

Gets the path to the TensorBoardOutputConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

logs()

Display the logs for Estimator’s training job.

If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

property model_data

The model location in S3. Only set if Estimator has been fit().

Type

Str or dict

prepare_workflow_for_training(job_name=None)

Calls _prepare_for_training. Used when setting up a workflow.

Parameters

job_name (str) – Name of the training job to be created. If not specified, one is generated, using the base name given to the constructor if applicable.

register(content_types=None, response_types=None, inference_instances=None, transform_instances=None, image_uri=None, model_package_name=None, model_package_group_name=None, model_metrics=None, metadata_properties=None, marketplace_cert=False, approval_status=None, description=None, compile_model_family=None, model_name=None, drift_check_baselines=None, customer_metadata_properties=None, domain=None, sample_payload_url=None, task=None, framework=None, framework_version=None, nearest_model_name=None, data_input_configuration=None, skip_model_validation=None, source_uri=None, model_card=None, **kwargs)

Creates a model package for creating SageMaker models or listing on Marketplace.

Parameters
  • content_types (list) – The supported MIME types for the input data.

  • response_types (list) – The supported MIME types for the output data.

  • inference_instances (list) – A list of the instance types that are used to generate inferences in real-time (default: None).

  • transform_instances (list) – A list of the instance types on which a transformation job can be run or on which an endpoint can be deployed (default: None).

  • image_uri (str) – The container image uri for Model Package, if not specified, Estimator’s training container image will be used (default: None).

  • model_package_name (str) – Model Package name, exclusive to model_package_group_name, using model_package_name makes the Model Package un-versioned (default: None).

  • model_package_group_name (str) – Model Package Group name, exclusive to model_package_name, using model_package_group_name makes the Model Package versioned (default: None).

  • model_metrics (ModelMetrics) – ModelMetrics object (default: None).

  • metadata_properties (MetadataProperties) – MetadataProperties (default: None).

  • marketplace_cert (bool) – A boolean value indicating if the Model Package is certified for AWS Marketplace (default: False).

  • approval_status (str) – Model Approval Status, values can be “Approved”, “Rejected”, or “PendingManualApproval” (default: “PendingManualApproval”).

  • description (str) – Model Package description (default: None).

  • compile_model_family (str) – Instance family for compiled model, if specified, a compiled model will be used (default: None).

  • model_name (str) – User defined model name (default: None).

  • drift_check_baselines (DriftCheckBaselines) – DriftCheckBaselines object (default: None).

  • customer_metadata_properties (dict[str, str]) – A dictionary of key-value paired metadata properties (default: None).

  • domain (str) – Domain values can be “COMPUTER_VISION”, “NATURAL_LANGUAGE_PROCESSING”, “MACHINE_LEARNING” (default: None).

  • sample_payload_url (str) – The S3 path where the sample payload is stored (default: None).

  • task (str) – Task values which are supported by Inference Recommender are “FILL_MASK”, “IMAGE_CLASSIFICATION”, “OBJECT_DETECTION”, “TEXT_GENERATION”, “IMAGE_SEGMENTATION”, “CLASSIFICATION”, “REGRESSION”, “OTHER” (default: None).

  • framework (str) – Machine learning framework of the model package container image (default: None).

  • framework_version (str) – Framework version of the Model Package Container Image (default: None).

  • nearest_model_name (str) – Name of a pre-trained machine learning benchmarked by Amazon SageMaker Inference Recommender (default: None).

  • data_input_configuration (str) – Input object for the model (default: None).

  • skip_model_validation (str) – Indicates if you want to skip model validation. Values can be “All” or “None” (default: None).

  • source_uri (str) – The URI of the source for the model package (default: None).

  • model_card (ModeCard or ModelPackageModelCard) – document contains qualitative and quantitative information about a model (default: None).

  • **kwargs – Passed to invocation of create_model(). Implementations may customize create_model() to accept **kwargs to customize model creation during deploy. For more, see the implementation docs.

Returns

A string of SageMaker Model Package ARN.

Return type

str

property training_job_analytics

Return a TrainingJobAnalytics object for the current training job.

transformer(instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, env=None, max_concurrent_transforms=None, max_payload=None, tags=None, role=None, volume_kms_key=None, vpc_config_override='VPC_CONFIG_DEFAULT', enable_network_isolation=None, model_name=None)

Return a Transformer that uses a SageMaker Model based on the training job.

It reuses the SageMaker Session and base job name used by the Estimator.

Parameters
  • instance_count (int) – Number of EC2 instances to use.

  • instance_type (str) – Type of EC2 instance to use, for example, ‘ml.c4.xlarge’.

  • strategy (str) – The strategy used to decide how to batch records in a single request (default: None). Valid values: ‘MultiRecord’ and ‘SingleRecord’.

  • assemble_with (str) – How the output is assembled (default: None). Valid values: ‘Line’ or ‘None’.

  • output_path (str) – S3 location for saving the transform result. If not specified, results are stored to a default bucket.

  • output_kms_key (str) – Optional. KMS key ID for encrypting the transform output (default: None).

  • accept (str) – The accept header passed by the client to the inference endpoint. If it is supported by the endpoint, it will be the format of the batch transform output.

  • env (dict) – Environment variables to be set for use during the transform job (default: None).

  • max_concurrent_transforms (int) – The maximum number of HTTP requests to be made to each individual transform container at one time.

  • max_payload (int) – Maximum size of the payload in a single HTTP request to the container in MB.

  • tags (Optional[Tags]) – Tags for labeling a transform job. If none specified, then the tags used for the training job are used for the transform job.

  • role (str) – The ExecutionRoleArn IAM Role ARN for the Model, which is also used during transform jobs. If not specified, the role from the Estimator will be used.

  • volume_kms_key (str) – Optional. KMS key ID for encrypting the volume attached to the ML compute instance (default: None).

  • vpc_config_override (dict[str, list[str]]) –

    Optional override for the VpcConfig set on the model. Default: use subnets and security groups from this Estimator.

    • ’Subnets’ (list[str]): List of subnet ids.

    • ’SecurityGroupIds’ (list[str]): List of security group ids.

  • enable_network_isolation (bool) – Specifies whether container will run in network isolation mode. Network isolation mode restricts the container access to outside networks (such as the internet). The container does not make any inbound or outbound network calls. If True, a channel named “code” will be created for any user entry script for inference. Also known as Internet-free mode. If not specified, this setting is taken from the estimator’s current configuration.

  • model_name (str) – Name to use for creating an Amazon SageMaker model. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

update_profiler(rules=None, system_monitor_interval_millis=None, s3_output_path=None, framework_profile_params=None, disable_framework_metrics=False)

Update training jobs to enable profiling.

This method updates the profiler_config parameter and initiates Debugger built-in rules for profiling.

Parameters
  • rules (list[ProfilerRule]) – A list of ProfilerRule objects to define rules for continuous analysis with SageMaker Debugger. Currently, you can only add new profiler rules during the training job. (default: None)

  • s3_output_path (str) – The location in S3 to store the output. If profiler is enabled once, s3_output_path cannot be changed. (default: None)

  • system_monitor_interval_millis (int) – How often profiling system metrics are collected; Unit: Milliseconds (default: None)

  • framework_profile_params (FrameworkProfile) – A parameter object for framework metrics profiling. Configure it using the FrameworkProfile class. To use the default framework profile parameters, pass FrameworkProfile(). For more information about the default values, see FrameworkProfile. (default: None)

  • disable_framework_metrics (bool) – Specify whether to disable all the framework metrics. This won’t update system metrics and the Debugger built-in rules for monitoring. To stop both monitoring and profiling, use the desable_profiling method. (default: False)

Attention

Updating the profiling configuration for TensorFlow dataloader profiling is currently not available. If you started a TensorFlow training job only with monitoring and want to enable profiling while the training job is running, the dataloader profiling cannot be updated.

uploaded_code: Optional[UploadedCode]
class sagemaker.jumpstart.estimator.JumpStartEstimator(model_id=None, model_version=None, tolerate_vulnerable_model=None, tolerate_deprecated_model=None, region=None, image_uri=None, role=None, instance_count=None, instance_type=None, keep_alive_period_in_seconds=None, volume_size=None, volume_kms_key=None, max_run=None, input_mode=None, output_path=None, output_kms_key=None, base_job_name=None, sagemaker_session=None, hyperparameters=None, tags=None, subnets=None, security_group_ids=None, model_uri=None, model_channel_name=None, metric_definitions=None, encrypt_inter_container_traffic=None, use_spot_instances=None, max_wait=None, checkpoint_s3_uri=None, checkpoint_local_path=None, enable_network_isolation=None, rules=None, debugger_hook_config=None, tensorboard_output_config=None, enable_sagemaker_metrics=None, profiler_config=None, disable_profiler=None, environment=None, max_retry_attempts=None, source_dir=None, git_config=None, container_log_level=None, code_location=None, entry_point=None, dependencies=None, instance_groups=None, training_repository_access_mode=None, training_repository_credentials_provider_arn=None, enable_infra_check=None, container_entry_point=None, container_arguments=None, disable_output_compression=None, enable_remote_debug=None, enable_session_tag_chaining=None)

Bases: Estimator

JumpStartEstimator class.

This class sets defaults based on the model ID and version.

Initializes a JumpStartEstimator.

This method sets model-specific defaults for the Estimator.__init__ method.

Only model ID is required to instantiate this class, however any field can be overriden. Any field set to None does not get passed to the parent class method.

Parameters
  • model_id (Optional[str]) – JumpStart model ID to use. See https://sagemaker.readthedocs.io/en/stable/doc_utils/pretrainedmodels.html for list of model IDs.

  • model_version (Optional[str]) – Version for JumpStart model to use (Default: None).

  • tolerate_vulnerable_model (Optional[bool]) – True if vulnerable versions of model specifications should be tolerated (exception not raised). If False, raises an exception if the script used by this version of the model has dependencies with known security vulnerabilities. (Default: None).

  • tolerate_deprecated_model (Optional[bool]) – True if deprecated models should be tolerated (exception not raised). False if these models should raise an exception. (Default: None).

  • region (Optional[str]) – The AWS region in which to launch the model. (Default: None).

  • image_uri (Optional[Union[str, PipelineVariable]]) – The container image to use for training. (Default: None).

  • role (Optional[str]) – An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. After the endpoint is created, the inference code might use the IAM role, if it needs to access an AWS resource. (Default: None).

  • instance_count (Optional[Union[int, PipelineVariable]]) – Number of Amazon EC2 instances to usefor training. Required if instance_groups is not set. (Default: None).

  • instance_type (Optional[Union[str, PipelineVariable]]) – Type of EC2 instance to use for training, for example, 'ml.c4.xlarge'. Required if instance_groups is not set. (Default: None).

  • keep_alive_period_in_seconds (Optional[int]) – The duration of time in seconds to retain configured resources in a warm pool for subsequent training jobs. (Default: None).

  • volume_size (Optional[int, PipelineVariable]) –

    Size in GB of the storage volume to use for storing input and output data during training.

    Must be large enough to store training data if File mode is used, which is the default mode.

    When you use an ML instance with the EBS-only storage option such as ml.c5 and ml.p2, you must define the size of the EBS volume through the volume_size parameter in the estimator class.

    Note

    When you use an ML instance with NVMe SSD volumes such as ml.p4d, ml.g4dn, and ml.g5, do not include this parameter in the estimator configuration. If you use one of those ML instance types, SageMaker doesn’t provision Amazon EBS General Purpose SSD (gp2) storage nor take this parameter to adjust the NVMe instance storage. Available storage is fixed to the NVMe instance storage capacity. SageMaker configures storage paths for training datasets, checkpoints, model artifacts, and outputs to use the entire capacity of the instance storage.

    Note that if you include this parameter and specify a number that exceeds the size of the NVMe volume attached to the instance type, SageMaker returns an Invalid VolumeSizeInGB error.

    To look up instance types and their instance storage types and volumes, see Amazon EC2 Instance Types.

    To find the default local paths defined by the SageMaker training platform, see Amazon SageMaker Training Storage Folders for Training Datasets, Checkpoints, Model Artifacts, and Outputs. (Default: None).

  • volume_kms_key (Optional[Union[str, PipelineVariable]]) – KMS key ID for encrypting EBS volume attached to the training instance. (Default: None).

  • max_run (Optional[Union[int, PipelineVariable]]) – Timeout in seconds for training. After this amount of time Amazon SageMaker terminates the job regardless of its current status. (Default: None).

  • input_mode (Optional[Union[str, PipelineVariable]]) –

    The input mode that the algorithm supports. Valid modes:

    • ’File’ - Amazon SageMaker copies the training dataset from the S3 location to a local directory.

    • ’Pipe’ - Amazon SageMaker streams data directly from S3 to the container via a Unix-named pipe.

    This argument can be overriden on a per-channel basis using sagemaker.inputs.TrainingInput.input_mode. (Default: None).

  • output_path (Optional[Union[str, PipelineVariable]]) – S3 location for saving the training result (model artifacts and output files). If not specified, results are stored to a default bucket. If the bucket with the specific name does not exist, the estimator creates the bucket during the fit() method execution. (Default: None).

  • output_kms_key (Optional[Union[str, PipelineVariable]]) – KMS key ID for encrypting the training output. (Default: None).

  • base_job_name (Optional[str]) – Prefix for training job name when the fit() method launches. If not specified, the estimator generates a default job name, based on the training image name and current timestamp. (Default: None).

  • sagemaker_session (Optional[sagemaker.session.Session]) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain. (Default: None).

  • hyperparameters (Optional[Union[dict[str, str],dict[str, PipelineVariable]]]) –

    Dictionary containing the hyperparameters to initialize this estimator with.

    Caution

    You must not include any security-sensitive information, such as account access IDs, secrets, and tokens, in the dictionary for configuring hyperparameters. SageMaker rejects the training job request and returns an validation error for detected credentials, if such user input is found.

    (Default: None).

  • tags (Optional[Tags]) – Tags for labeling a training job. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/API_Tag.html. (Default: None).

  • subnets (Optional[Union[list[str], list[PipelineVariable]]]) – List of subnet ids. If not specified training job will be created without VPC config. (Default: None).

  • security_group_ids (Optional[Union[list[str], list[PipelineVariable]]]) – List of security group ids. If not specified training job will be created without VPC config. (Default: None).

  • model_uri (Optional[str]) –

    URI where a pre-trained model is stored, either locally or in S3 (Default: None). If specified, the estimator will create a channel pointing to the model so the training job can download it. This model can be a ‘model.tar.gz’ from a previous training job, or other artifacts coming from a different source.

    In local mode, this should point to the path in which the model is located and not the file itself, as local Docker containers will try to mount the URI as a volume.

    More information: https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html#td-deserialization

    (Default: None).

  • model_channel_name (Optional[Union[str, PipelineVariable]]) – Name of the channel where ‘model_uri’ will be downloaded. (Default: None).

  • metric_definitions (Optional[list[dict[str, Union[str, PipelineVariable]]]]) – A list of dictionaries that defines the metric(s) used to evaluate the training jobs. Each dictionary contains two keys: ‘Name’ for the name of the metric, and ‘Regex’ for the regular expression used to extract the metric from the logs. This should be defined only for jobs that don’t use an Amazon algorithm. (Default: None).

  • encrypt_inter_container_traffic (Optional[Union[bool, PipelineVariable]]]) – Specifies whether traffic between training containers is encrypted for the training job (Default: None).

  • use_spot_instances (Optional[Union[bool, PipelineVariable]]) –

    Specifies whether to use SageMaker Managed Spot instances for training. If enabled then the max_wait arg should also be set.

    More information: https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html (Default: None).

  • max_wait (Optional[Union[int, PipelineVariable]]) – Timeout in seconds waiting for spot training job. After this amount of time Amazon SageMaker will stop waiting for managed spot training job to complete. (Default: None).

  • checkpoint_s3_uri (Optional[Union[str, PipelineVariable]]) – The S3 URI in which to persist checkpoints that the algorithm persists (if any) during training. (Default: None).

  • checkpoint_local_path (Optional[Union[str, PipelineVariable]]) – The local path that the algorithm writes its checkpoints to. SageMaker will persist all files under this path to checkpoint_s3_uri continually during training. On job startup the reverse happens - data from the s3 location is downloaded to this path before the algorithm is started. If the path is unset then SageMaker assumes the checkpoints will be provided under /opt/ml/checkpoints/. (Default: None).

  • enable_network_isolation (Optional[Union[bool, PipelineVariable]]) – Specifies whether container will run in network isolation mode. Network isolation mode restricts the container access to outside networks (such as the Internet). The container does not make any inbound or outbound network calls. Also known as Internet-free mode. (Default: None).

  • rules (Optional[list[RuleBase]]) –

    A list of RuleBase objects used to define SageMaker Debugger rules for real-time analysis (Default: None). For more information, see Continuous analyses through rules. (Default: None).

  • debugger_hook_config (Optional[Union[DebuggerHookConfig, bool]]) –

    Configuration for how debugging information is emitted with SageMaker Debugger. If not specified, a default one is created using the estimator’s output_path, unless the region does not support SageMaker Debugger. To disable SageMaker Debugger, set this parameter to False. For more information, see Capture real-time debugging data during model training in Amazon SageMaker. (Default: None).

  • tensorboard_output_config (TensorBoardOutputConfig) –

    Configuration for customizing debugging visualization using TensorBoard. For more information, see Capture real time tensorboard data. (Default: None).

  • enable_sagemaker_metrics (Optional[Union[bool, PipelineVariable]]) –

    enable SageMaker Metrics Time Series. For more information, see AlgorithmSpecification API. (Default: None).

  • profiler_config (Optional[ProfilerConfig]) – Configuration for how SageMaker Debugger collects monitoring and profiling information from your training job. If not specified, Debugger will be configured with a default configuration and will save system and framework metrics the estimator’s default output_path in Amazon S3. Use ProfilerConfig to configure this parameter. To disable SageMaker Debugger monitoring and profiling, set the disable_profiler parameter to True. (Default: None).

  • disable_profiler (Optional[bool]) – Specifies whether Debugger monitoring and profiling will be disabled. (Default: None).

  • environment (Optional[Union[dict[str, str], dict[str, PipelineVariable]]]) – Environment variables to be set for use during training job. (Default: None).

  • max_retry_attempts (Optional[Union[int, PipelineVariable]]) – The number of times to move a job to the STARTING status. You can specify between 1 and 30 attempts. If the value of attempts is greater than zero, the job is retried on InternalServerFailure the same number of attempts as the value. You can cap the total duration for your job by setting max_wait and max_run. (Default: None).

  • source_dir (Optional[Union[str, PipelineVariable]]) –

    The absolute, relative, or S3 URI Path to a directory with any other training source code dependencies aside from the entry point file. If source_dir is an S3 URI, it must point to a tar.gz file. Structure within this directory is preserved when training on Amazon SageMaker. If ‘git_config’ is provided, ‘source_dir’ should be a relative location to a directory in the Git repo. (Default: None).

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- train.py
    >>>         |----- test.py
    

    if you need ‘train.py’ as the entry point and ‘test.py’ as the training source code, you can assign entry_point=’train.py’, source_dir=’src’.

  • git_config (Optional[dict[str, str]]) –

    Git configurations used for cloning files, including repo, branch, commit, 2FA_enabled, username, password and token. The repo field is required. All other fields are optional. repo specifies the Git repository where your training script is stored. If you don’t provide branch, the default value ‘master’ is used. If you don’t provide commit, the latest commit in the specified branch is used.

    2FA_enabled, username, password and token are used for authentication. For GitHub (or other Git) accounts, set 2FA_enabled to ‘True’ if two-factor authentication is enabled for the account, otherwise set it to ‘False’. If you do not provide a value for 2FA_enabled, a default value of ‘False’ is used. CodeCommit does not support two-factor authentication, so do not provide “2FA_enabled” with CodeCommit repositories.

    For GitHub and other Git repos, when SSH URLs are provided, it doesn’t matter whether 2FA is enabled or disabled. You should either have no passphrase for the SSH key pairs or have the ssh-agent configured so that you will not be prompted for the SSH passphrase when you run the ‘git clone’ command with SSH URLs. When HTTPS URLs are provided, if 2FA is disabled, then either token or username and password are be used for authentication if provided. Token is prioritized. If 2FA is enabled, only token is used for authentication if provided. If required authentication info is not provided, the SageMaker Python SDK attempts to use local credentials to authenticate. If that fails, an error message is thrown.

    For CodeCommit repos, 2FA is not supported, so 2FA_enabled should not be provided. There is no token in CodeCommit, so token should also not be provided. When repo is an SSH URL, the requirements are the same as GitHub repos. When repo is an HTTPS URL, username and password are used for authentication if they are provided. If they are not provided, the SageMaker Python SDK attempts to use either the CodeCommit credential helper or local credential storage for authentication. (Default: None).

    Example The following config:

    >>> git_config = {'repo': 'https://github.com/aws/sagemaker-python-sdk.git',
    >>>               'branch': 'test-branch-git-config',
    >>>               'commit': '329bfcf884482002c05ff7f44f62599ebc9f445a'}
    

    results in cloning the repo specified in ‘repo’, then checking out the ‘master’ branch, and checking out the specified commit.

  • container_log_level (Optional[Union[int, PipelineVariable]]) – The log level to use within the container. Valid values are defined in the Python logging module. (Default: None).

  • code_location (Optional[str]) – The S3 prefix URI where custom code is uploaded (Default: None). You must not include a trailing slash because a string prepended with a “/” is appended to code_location. The code file uploaded to S3 is ‘code_location/job-name/source/sourcedir.tar.gz’. If not specified, the default code location is ‘s3://output_bucket/job-name/’. (Default: None).

  • entry_point (Optional[Union[str, PipelineVariable]]) –

    The absolute or relative path to the local Python source file that should be executed as the entry point to training. If source_dir is specified, then entry_point must point to a file located at the root of source_dir. If ‘git_config’ is provided, ‘entry_point’ should be a relative location to the Python source file in the Git repo. (Default: None).

    Example With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- train.py
    >>>         |----- test.py
    

    You can assign entry_point=’src/train.py’.

  • dependencies (Optional[list[str]]) –

    A list of absolute or relative paths to directories with any additional libraries that should be exported to the container. The library folders are copied to SageMaker in the same folder where the entrypoint is copied. If ‘git_config’ is provided, ‘dependencies’ should be a list of relative locations to directories with any additional libraries needed in the Git repo. This is not supported with “local code” in Local Mode. (Default: None).

    Example The following Estimator call:

    >>> Estimator(entry_point='train.py',
    ...           dependencies=['my/libs/common', 'virtual-env'])
    

    results in the following structure inside the container:

    >>> $ ls
    
    >>> opt/ml/code
    >>>     |------ train.py
    >>>     |------ common
    >>>     |------ virtual-env
    

  • instance_groups (Optional[list[sagemaker.instance_group.InstanceGroup]]) –

    A list of InstanceGroup objects for launching a training job with a heterogeneous cluster. For example:

    instance_groups=[
        sagemaker.InstanceGroup(
            'instance_group_name_1', 'ml.p3dn.24xlarge', 64),
        sagemaker.InstanceGroup(
            'instance_group_name_2', 'ml.c5n.18xlarge', 64)]
    

    For instructions on how to use InstanceGroup objects to configure a heterogeneous cluster through the SageMaker generic and framework estimator classes, see Train Using a Heterogeneous Cluster in the Amazon SageMaker developer guide. (Default: None).

  • training_repository_access_mode (Optional[str]) – Specifies how SageMaker accesses the Docker image that contains the training algorithm (Default: None). Set this to one of the following values: * ‘Platform’ - The training image is hosted in Amazon ECR. * ‘Vpc’ - The training image is hosted in a private Docker registry in your VPC. When it’s default to None, its behavior will be same as ‘Platform’ - image is hosted in ECR. (Default: None).

  • training_repository_credentials_provider_arn (Optional[str]) – The Amazon Resource Name (ARN) of an AWS Lambda function that provides credentials to authenticate to the private Docker registry where your training image is hosted (Default: None). When it’s set to None, SageMaker will not do authentication before pulling the image in the private Docker registry. (Default: None).

  • enable_infra_check (Optional[Union[bool, PipelineVariable]]) – Specifies whether it is running Sagemaker built-in infra check jobs.

  • container_entry_point (Optional[List[str]]) – The entrypoint script for a Docker container used to run a training job. This script takes precedence over the default train processing instructions.

  • container_arguments (Optional[List[str]]) – The arguments for a container used to run a training job.

  • disable_output_compression (Optional[bool]) – When set to true, Model is uploaded to Amazon S3 without compression after training finishes.

  • enable_remote_debug (bool or PipelineVariable) – Optional. Specifies whether RemoteDebug is enabled for the training job

  • enable_session_tag_chaining (bool or PipelineVariable) – Optional. Specifies whether SessionTagChaining is enabled for the training job

Raises

ValueError – If the model ID is not recognized by JumpStart.

fit(inputs=None, wait=True, logs=None, job_name=None, experiment_config=None)

Start training job by calling base Estimator class fit method.

Any field set to None does not get passed to the parent class method.

Parameters
  • inputs (Optional[Union[str, dict, sagemaker.inputs.TrainingInput, sagemaker.inputs.FileSystemInput]]) –

    Information about the training data. This can be one of four types:

    • (str) the S3 location where training data is saved, or a file:// path in

      local mode.

    • (dict[str, str] or dict[str, sagemaker.inputs.TrainingInput] or

      dict[str, sagemaker.inputs.FileSystemInput]) If using multiple channels for training data, you can specify a dict mapping channel names to strings or TrainingInput() objects or FileSystemInput() objects.

    • (sagemaker.inputs.TrainingInput) - channel configuration for S3 data sources

      that can provide additional information as well as the path to the training dataset. See sagemaker.inputs.TrainingInput() for full details.

    • (sagemaker.inputs.FileSystemInput) - channel configuration for

      a file system data source that can provide additional information as well as the path to the training dataset.

    (Default: None).

  • wait (Optional[bool]) – Whether the call should wait until the job completes. (Default: True).

  • logs (Optional[List[str]]) – A list of strings specifying which logs to print. Acceptable strings are “All”, “None”, “Training”, or “Rules”. To maintain backwards compatibility, boolean values are also accepted and converted to strings. Only meaningful when wait is True. (Default: None).

  • job_name (Optional[str]) – Training job name. If not specified, the estimator generates a default job name based on the training image name and current timestamp. (Default: None).

  • experiment_config (Optional[dict[str, str]]) – Experiment management configuration. Optionally, the dict can contain four keys: ‘ExperimentName’, ‘TrialName’, ‘TrialComponentDisplayName’ and ‘RunName’.. The behavior of setting these keys is as follows: * If ExperimentName is supplied but TrialName is not a Trial will be automatically created and the job’s Trial Component associated with the Trial. * If TrialName is supplied and the Trial already exists the job’s Trial Component will be associated with the Trial. * If both ExperimentName and TrialName are not supplied the trial component will be unassociated. * TrialComponentDisplayName is used for display in Studio. * Both ExperimentName and TrialName will be ignored if the Estimator instance is built with PipelineSession. However, the value of TrialComponentDisplayName is honored for display in Studio. (Default: None).

Return type

None

classmethod attach(training_job_name, model_id=None, model_version=None, sagemaker_session=<sagemaker.session.Session object>, model_channel_name='model')

Attach to an existing training job.

Create a JumpStartEstimator bound to an existing training job. After attaching, if the training job has a Complete status, it can be deploy() ed to create a SageMaker Endpoint and return a Predictor.

If the training job is in progress, attach will block until the training job completes, but logs of the training job will not display. To see the logs content, please call logs()

Examples

>>> my_estimator.fit(wait=False)
>>> training_job_name = my_estimator.latest_training_job.name
Later on:
>>> attached_estimator = JumpStartEstimator.attach(training_job_name, model_id)
>>> attached_estimator.logs()
>>> attached_estimator.deploy()
Parameters
  • training_job_name (str) – The name of the training job to attach to.

  • model_id (str) – The name of the JumpStart model id associated with the training job.

  • model_version (str) – Optional. The version of the JumpStart model id associated with the training job. (Default: “*”).

  • sagemaker_session (sagemaker.session.Session) – Optional. Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).

  • model_channel_name (str) – Optional. Name of the channel where pre-trained model data will be downloaded (default: ‘model’). If no channel with the same name exists in the training job, this option will be ignored.

Returns

Instance of the calling JumpStartEstimator Class with the attached training job.

Raises

ValueError – if the model ID or version cannot be inferred from the training job.

Return type

JumpStartEstimator

deploy(initial_instance_count=None, instance_type=None, serializer=None, deserializer=None, accelerator_type=None, endpoint_name=None, tags=None, kms_key=None, wait=True, data_capture_config=None, async_inference_config=None, serverless_inference_config=None, volume_size=None, model_data_download_timeout=None, container_startup_health_check_timeout=None, inference_recommendation_id=None, explainer_config=None, image_uri=None, role=None, predictor_cls=None, env=None, model_name=None, vpc_config=None, sagemaker_session=None, enable_network_isolation=None, model_kms_key=None, image_config=None, source_dir=None, code_location=None, entry_point=None, container_log_level=None, dependencies=None, git_config=None, use_compiled_model=False)

Creates endpoint from training job.

Calls base Estimator class deploy method.

Any field set to None does not get passed to the parent class method.

Parameters
  • initial_instance_count (Optional[int]) – The initial number of instances to run in the Endpoint created from this Model. If not using serverless inference or the model has not called right_size(), then it need to be a number larger or equals to 1. (Default: None)

  • instance_type (Optional[str]) – The EC2 instance type to deploy this Model to. For example, ‘ml.p2.xlarge’, or ‘local’ for local mode. If not using serverless inference or the model has not called right_size(), then it is required to deploy a model. (Default: None)

  • serializer (Optional[BaseSerializer]) – A serializer object, used to encode data for an inference endpoint (Default: None). If serializer is not None, then serializer will override the default serializer. The default serializer is set by the predictor_cls. (Default: None).

  • deserializer (Optional[BaseDeserializer]) – A deserializer object, used to decode data from an inference endpoint (Default: None). If deserializer is not None, then deserializer will override the default deserializer. The default deserializer is set by the predictor_cls. (Default: None).

  • accelerator_type (Optional[str]) – Type of Elastic Inference accelerator to deploy this model for model loading and inference, for example, ‘ml.eia1.medium’. If not specified, no Elastic Inference accelerator will be attached to the endpoint. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html (Default: None).

  • endpoint_name (Optional[str]) – The name of the endpoint to create (default: None). If not specified, a unique endpoint name will be created. (Default: None).

  • tags (Optional[Tags]) – Tags to attach to this specific endpoint. (Default: None).

  • kms_key (Optional[str]) – The ARN of the KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint. (Default: None).

  • wait (Optional[bool]) – Whether the call should wait until the deployment of this model completes. (Default: True).

  • data_capture_config (Optional[sagemaker.model_monitor.DataCaptureConfig]) – Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. (Default: None).

  • async_inference_config (Optional[sagemaker.model_monitor.AsyncInferenceConfig]) – Specifies configuration related to async endpoint. Use this configuration when trying to create async endpoint and make async inference. If empty config object passed through, will use default config to deploy async endpoint. Deploy a real-time endpoint if it’s None. (Default: None)

  • serverless_inference_config (Optional[sagemaker.serverless.ServerlessInferenceConfig]) – Specifies configuration related to serverless endpoint. Use this configuration when trying to create serverless endpoint and make serverless inference. If empty object passed through, will use pre-defined values in ServerlessInferenceConfig class to deploy serverless endpoint. Deploy an instance based endpoint if it’s None. (Default: None)

  • volume_size (Optional[int]) – The size, in GB, of the ML storage volume attached to individual inference instance associated with the production variant. Currenly only Amazon EBS gp2 storage volumes are supported. (Default: None).

  • model_data_download_timeout (Optional[int]) – The timeout value, in seconds, to download and extract model data from Amazon S3 to the individual inference instance associated with this production variant. (Default: None).

  • container_startup_health_check_timeout (Optional[int]) – The timeout value, in seconds, for your inference container to pass health check by SageMaker Hosting. For more information about health check see: https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-algo-ping-requests (Default: None).

  • inference_recommendation_id (Optional[str]) – The recommendation id which specifies the recommendation you picked from inference recommendation job results and would like to deploy the model and endpoint with recommended parameters. (Default: None).

  • explainer_config (Optional[sagemaker.explainer.ExplainerConfig]) – Specifies online explainability configuration for use with Amazon SageMaker Clarify. (Default: None).

  • image_uri (Optional[Union[str, PipelineVariable]]) – A Docker image URI. (Default: None).

  • role (Optional[str]) – An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. After the endpoint is created, the inference code might use the IAM role if it needs to access some AWS resources. It can be null if this is being used to create a Model to pass to a PipelineModel which has its own Role field. (Default: None).

  • predictor_cls (Optional[callable[string, sagemaker.session.Session]]) – A function to call to create a predictor (Default: None). If not None, deploy will return the result of invoking this function on the created endpoint name. (Default: None).

  • env (Optional[dict[str, str] or dict[str, PipelineVariable]]) – Environment variables to run with image_uri when hosted in SageMaker. (Default: None).

  • model_name (Optional[str]) – The model name. If None, a default model name will be selected on each deploy. (Default: None).

  • vpc_config (Optional[Union[dict[str, list[str]],dict[str, list[PipelineVariable]]]]) – The VpcConfig set on the model (Default: None) * ‘Subnets’ (list[str]): List of subnet ids. * ‘SecurityGroupIds’ (list[str]): List of security group ids. (Default: None).

  • sagemaker_session (Optional[sagemaker.session.Session]) – A SageMaker Session object, used for SageMaker interactions (Default: None). If not specified, one is created using the default AWS configuration chain. (Default: None).

  • enable_network_isolation (Optional[Union[bool, PipelineVariable]]) – If True, enables network isolation in the endpoint, isolating the model container. No inbound or outbound network calls can be made to or from the model container. (Default: None).

  • model_kms_key (Optional[str]) – KMS key ARN used to encrypt the repacked model archive file if the model is repacked. (Default: None).

  • image_config (Optional[Union[dict[str, str], dict[str, PipelineVariable]]]) – Specifies whether the image of model container is pulled from ECR, or private registry in your VPC. By default it is set to pull model container image from ECR. (Default: None).

  • source_dir (Optional[str]) –

    The absolute, relative, or S3 URI Path to a directory with any other training source code dependencies aside from the entry point file (Default: None). If source_dir is an S3 URI, it must point to a tar.gz file. Structure within this directory is preserved when training on Amazon SageMaker. If ‘git_config’ is provided, ‘source_dir’ should be a relative location to a directory in the Git repo. If the directory points to S3, no code is uploaded and the S3 location is used instead. (Default: None).

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- inference.py
    >>>         |----- test.py
    

    You can assign entry_point=’inference.py’, source_dir=’src’.

  • code_location (Optional[str]) – Name of the S3 bucket where custom code is uploaded (Default: None). If not specified, the default bucket created by sagemaker.session.Session is used. (Default: None).

  • entry_point (Optional[str]) –

    The absolute or relative path to the local Python source file that should be executed as the entry point to model hosting. (Default: None). If source_dir is specified, then entry_point must point to a file located at the root of source_dir. If ‘git_config’ is provided, ‘entry_point’ should be a relative location to the Python source file in the Git repo.

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- inference.py
    >>>         |----- test.py
    

    You can assign entry_point=’src/inference.py’.

    (Default: None).

  • container_log_level (Optional[Union[int, PipelineVariable]]) – Log level to use within the container. Valid values are defined in the Python logging module. (Default: None).

  • dependencies (Optional[list[str]]) –

    A list of absolute or relative paths to directories with any additional libraries that should be exported to the container (default: []). The library folders are copied to SageMaker in the same folder where the entrypoint is copied. If ‘git_config’ is provided, ‘dependencies’ should be a list of relative locations to directories with any additional libraries needed in the Git repo. If the `source_dir` points to S3, code will be uploaded and the S3 location will be used instead.

    Example

    The following call

    >>> Model(entry_point='inference.py',
    ...       dependencies=['my/libs/common', 'virtual-env'])
    

    results in the following structure inside the container:

    >>> $ ls
    
    >>> opt/ml/code
    >>>     |------ inference.py
    >>>     |------ common
    >>>     |------ virtual-env
    

    This is not supported with “local code” in Local Mode. (Default: None).

  • git_config (Optional[dict[str, str]]) –

    Git configurations used for cloning files, including repo, branch, commit, 2FA_enabled, username, password and token. The repo field is required. All other fields are optional. repo specifies the Git repository where your training script is stored. If you don’t provide branch, the default value ‘master’ is used. If you don’t provide commit, the latest commit in the specified branch is used.

    Example

    The following config:

    >>> git_config = {'repo': 'https://github.com/aws/sagemaker-python-sdk.git',
    >>>               'branch': 'test-branch-git-config',
    >>>               'commit': '329bfcf884482002c05ff7f44f62599ebc9f445a'}
    

    results in cloning the repo specified in ‘repo’, then checking out the ‘master’ branch, and checking out the specified commit.

    2FA_enabled, username, password and token are used for authentication. For GitHub (or other Git) accounts, set 2FA_enabled to ‘True’ if two-factor authentication is enabled for the account, otherwise set it to ‘False’. If you do not provide a value for 2FA_enabled, a default value of ‘False’ is used. CodeCommit does not support two-factor authentication, so do not provide “2FA_enabled” with CodeCommit repositories.

    For GitHub and other Git repos, when SSH URLs are provided, it doesn’t matter whether 2FA is enabled or disabled. You should either have no passphrase for the SSH key pairs or have the ssh-agent configured so that you will not be prompted for the SSH passphrase when you run the ‘git clone’ command with SSH URLs. When HTTPS URLs are provided, if 2FA is disabled, then either token or username and password are be used for authentication if provided. Token is prioritized. If 2FA is enabled, only token is used for authentication if provided. If required authentication info is not provided, the SageMaker Python SDK attempts to use local credentials to authenticate. If that fails, an error message is thrown.

    For CodeCommit repos, 2FA is not supported, so 2FA_enabled should not be provided. There is no token in CodeCommit, so token should also not be provided. When repo is an SSH URL, the requirements are the same as GitHub repos. When repo is an HTTPS URL, username and password are used for authentication if they are provided. If they are not provided, the SageMaker Python SDK attempts to use either the CodeCommit credential helper or local credential storage for authentication. (Default: None).

  • use_compiled_model (bool) – Flag to select whether to use compiled (optimized) model. (Default: False).

Return type

PredictorBase

CONTAINER_CODE_CHANNEL_SOURCEDIR_PATH = '/opt/ml/input/data/code/sourcedir.tar.gz'
INSTANCE_TYPE = 'sagemaker_instance_type'
JOB_CLASS_NAME = 'training-job'
LAUNCH_MPI_ENV_NAME = 'sagemaker_mpi_enabled'
LAUNCH_MWMS_ENV_NAME = 'sagemaker_multi_worker_mirrored_strategy_enabled'
LAUNCH_PS_ENV_NAME = 'sagemaker_parameter_server_enabled'
LAUNCH_PT_XLA_ENV_NAME = 'sagemaker_pytorch_xla_multi_worker_enabled'
LAUNCH_SM_DDP_ENV_NAME = 'sagemaker_distributed_dataparallel_enabled'
MPI_CUSTOM_MPI_OPTIONS = 'sagemaker_mpi_custom_mpi_options'
MPI_NUM_PROCESSES_PER_HOST = 'sagemaker_mpi_num_of_processes_per_host'
SM_DDP_CUSTOM_MPI_OPTIONS = 'sagemaker_distributed_dataparallel_custom_mpi_options'
compile_model(target_instance_family, input_shape, output_path, framework=None, framework_version=None, compile_max_run=900, tags=None, target_platform_os=None, target_platform_arch=None, target_platform_accelerator=None, compiler_options=None, **kwargs)

Compile a Neo model using the input model.

Parameters
Returns

A SageMaker Model object. See Model() for full details.

Return type

sagemaker.model.Model

create_model(role=None, image_uri=None, predictor_cls=None, vpc_config_override='VPC_CONFIG_DEFAULT', **kwargs)

Create a model to deploy.

The serializer and deserializer arguments are only used to define a default Predictor. They are ignored if an explicit predictor class is passed in. Other arguments are passed through to the Model class.

Parameters
  • role (str) – The ExecutionRoleArn IAM Role ARN for the Model, which is also used during transform jobs. If not specified, the role from the Estimator will be used.

  • image_uri (str) – A Docker image URI to use for deploying the model. Defaults to the image used for training.

  • predictor_cls (Predictor) – The predictor class to use when deploying the model.

  • vpc_config_override (dict[str, list[str]]) – Optional override for VpcConfig set on the model. Default: use subnets and security groups from this Estimator. * ‘Subnets’ (list[str]): List of subnet ids. * ‘SecurityGroupIds’ (list[str]): List of security group ids.

  • **kwargs – Additional parameters passed to Model

Tip

You can find additional parameters for using this method at Model.

Returns

(sagemaker.model.Model) a Model ready for deployment.

delete_endpoint(**kwargs)
disable_profiling()

Update the current training job in progress to disable profiling.

Debugger stops collecting the system and framework metrics and turns off the Debugger built-in monitoring and profiling rules.

disable_remote_debug()

Disable remote debug for a training job.

enable_default_profiling()

Update training job to enable Debugger monitoring.

This method enables Debugger monitoring with the default profiler_config parameter to collect system metrics and the default built-in profiler_report rule. Framework metrics won’t be saved. To update training job to emit framework metrics, you can use update_profiler method and specify the framework metrics you want to enable.

This method is callable when the training job is in progress while Debugger monitoring is disabled.

enable_network_isolation()

Return True if this Estimator will need network isolation to run.

Returns

Whether this Estimator needs network isolation or not.

Return type

bool

enable_remote_debug()

Enable remote debug for a training job.

get_app_url(app_type, open_in_default_web_browser=True, create_presigned_domain_url=False, domain_id=None, user_profile_name=None, optional_create_presigned_url_kwargs=None)

Generate a URL to help access the specified app hosted in Amazon SageMaker Studio.

Parameters
  • app_type (str or SupportedInteractiveAppTypes) – Required. The app type available in SageMaker Studio to return a URL to.

  • open_in_default_web_browser (bool) – Optional. When True, the URL will attempt to be opened in the environment’s default web browser. Otherwise, the resulting URL will be returned by this function. Default: True

  • create_presigned_domain_url (bool) – Optional. Determines whether a presigned domain URL should be generated instead of an unsigned URL. This only applies when called from outside of a SageMaker Studio environment. If this is set to True inside of a SageMaker Studio environment, it will be ignored. Default: False

  • domain_id (str) – Optional. The AWS Studio domain that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • user_profile_name (str) – Optional. The AWS Studio user profile that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • optional_create_presigned_url_kwargs (dict) – Optional. This parameter should be passed when a user outside of Studio wants a presigned URL to the TensorBoard application and wants to modify the optional parameters of the create_presigned_domain_url call. Default: None

Returns

A URL for the requested app in SageMaker Studio.

Return type

str

get_remote_debug_config()

dict: Return the configuration of RemoteDebug

get_session_chaining_config()

dict: Return the configuration of SessionChaining

get_vpc_config(vpc_config_override='VPC_CONFIG_DEFAULT')

Returns VpcConfig dict either from this Estimator’s subnets and security groups.

Or else validate and return an optional override value.

Parameters

vpc_config_override

hyperparameters()

Returns the hyperparameters as a dictionary to use for training.

The fit() method, that does the model training, calls this method to find the hyperparameters you specified.

latest_job_debugger_artifacts_path()

Gets the path to the DebuggerHookConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_profiler_artifacts_path()

Gets the path to the profiling output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_tensorboard_artifacts_path()

Gets the path to the TensorBoardOutputConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

logs()

Display the logs for Estimator’s training job.

If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

property model_data

The model location in S3. Only set if Estimator has been fit().

Type

Str or dict

prepare_workflow_for_training(job_name=None)

Calls _prepare_for_training. Used when setting up a workflow.

Parameters

job_name (str) – Name of the training job to be created. If not specified, one is generated, using the base name given to the constructor if applicable.

register(content_types=None, response_types=None, inference_instances=None, transform_instances=None, image_uri=None, model_package_name=None, model_package_group_name=None, model_metrics=None, metadata_properties=None, marketplace_cert=False, approval_status=None, description=None, compile_model_family=None, model_name=None, drift_check_baselines=None, customer_metadata_properties=None, domain=None, sample_payload_url=None, task=None, framework=None, framework_version=None, nearest_model_name=None, data_input_configuration=None, skip_model_validation=None, source_uri=None, model_card=None, **kwargs)

Creates a model package for creating SageMaker models or listing on Marketplace.

Parameters
  • content_types (list) – The supported MIME types for the input data.

  • response_types (list) – The supported MIME types for the output data.

  • inference_instances (list) – A list of the instance types that are used to generate inferences in real-time (default: None).

  • transform_instances (list) – A list of the instance types on which a transformation job can be run or on which an endpoint can be deployed (default: None).

  • image_uri (str) – The container image uri for Model Package, if not specified, Estimator’s training container image will be used (default: None).

  • model_package_name (str) – Model Package name, exclusive to model_package_group_name, using model_package_name makes the Model Package un-versioned (default: None).

  • model_package_group_name (str) – Model Package Group name, exclusive to model_package_name, using model_package_group_name makes the Model Package versioned (default: None).

  • model_metrics (ModelMetrics) – ModelMetrics object (default: None).

  • metadata_properties (MetadataProperties) – MetadataProperties (default: None).

  • marketplace_cert (bool) – A boolean value indicating if the Model Package is certified for AWS Marketplace (default: False).

  • approval_status (str) – Model Approval Status, values can be “Approved”, “Rejected”, or “PendingManualApproval” (default: “PendingManualApproval”).

  • description (str) – Model Package description (default: None).

  • compile_model_family (str) – Instance family for compiled model, if specified, a compiled model will be used (default: None).

  • model_name (str) – User defined model name (default: None).

  • drift_check_baselines (DriftCheckBaselines) – DriftCheckBaselines object (default: None).

  • customer_metadata_properties (dict[str, str]) – A dictionary of key-value paired metadata properties (default: None).

  • domain (str) – Domain values can be “COMPUTER_VISION”, “NATURAL_LANGUAGE_PROCESSING”, “MACHINE_LEARNING” (default: None).

  • sample_payload_url (str) – The S3 path where the sample payload is stored (default: None).

  • task (str) – Task values which are supported by Inference Recommender are “FILL_MASK”, “IMAGE_CLASSIFICATION”, “OBJECT_DETECTION”, “TEXT_GENERATION”, “IMAGE_SEGMENTATION”, “CLASSIFICATION”, “REGRESSION”, “OTHER” (default: None).

  • framework (str) – Machine learning framework of the model package container image (default: None).

  • framework_version (str) – Framework version of the Model Package Container Image (default: None).

  • nearest_model_name (str) – Name of a pre-trained machine learning benchmarked by Amazon SageMaker Inference Recommender (default: None).

  • data_input_configuration (str) – Input object for the model (default: None).

  • skip_model_validation (str) – Indicates if you want to skip model validation. Values can be “All” or “None” (default: None).

  • source_uri (str) – The URI of the source for the model package (default: None).

  • model_card (ModeCard or ModelPackageModelCard) – document contains qualitative and quantitative information about a model (default: None).

  • **kwargs – Passed to invocation of create_model(). Implementations may customize create_model() to accept **kwargs to customize model creation during deploy. For more, see the implementation docs.

Returns

A string of SageMaker Model Package ARN.

Return type

str

set_hyperparameters(**kwargs)

Sets the hyperparameter dictionary to use for training.

The hyperparameters are made accessible as a dict[str, str] to the training code on SageMaker. For convenience, this accepts other types for keys and values, but str() will be called to convert them before training.

If a source directory is specified, this method escapes the dict argument as JSON, and updates the private hyperparameter attribute.

training_image_uri()

Returns the docker image to use for training.

The fit() method, that does the model training, calls this method to find the image to use for model training.

property training_job_analytics

Return a TrainingJobAnalytics object for the current training job.

transformer(instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, env=None, max_concurrent_transforms=None, max_payload=None, tags=None, role=None, volume_kms_key=None, vpc_config_override='VPC_CONFIG_DEFAULT', enable_network_isolation=None, model_name=None)

Return a Transformer that uses a SageMaker Model based on the training job.

It reuses the SageMaker Session and base job name used by the Estimator.

Parameters
  • instance_count (int) – Number of EC2 instances to use.

  • instance_type (str) – Type of EC2 instance to use, for example, ‘ml.c4.xlarge’.

  • strategy (str) – The strategy used to decide how to batch records in a single request (default: None). Valid values: ‘MultiRecord’ and ‘SingleRecord’.

  • assemble_with (str) – How the output is assembled (default: None). Valid values: ‘Line’ or ‘None’.

  • output_path (str) – S3 location for saving the transform result. If not specified, results are stored to a default bucket.

  • output_kms_key (str) – Optional. KMS key ID for encrypting the transform output (default: None).

  • accept (str) – The accept header passed by the client to the inference endpoint. If it is supported by the endpoint, it will be the format of the batch transform output.

  • env (dict) – Environment variables to be set for use during the transform job (default: None).

  • max_concurrent_transforms (int) – The maximum number of HTTP requests to be made to each individual transform container at one time.

  • max_payload (int) – Maximum size of the payload in a single HTTP request to the container in MB.

  • tags (Optional[Tags]) – Tags for labeling a transform job. If none specified, then the tags used for the training job are used for the transform job.

  • role (str) – The ExecutionRoleArn IAM Role ARN for the Model, which is also used during transform jobs. If not specified, the role from the Estimator will be used.

  • volume_kms_key (str) – Optional. KMS key ID for encrypting the volume attached to the ML compute instance (default: None).

  • vpc_config_override (dict[str, list[str]]) –

    Optional override for the VpcConfig set on the model. Default: use subnets and security groups from this Estimator.

    • ’Subnets’ (list[str]): List of subnet ids.

    • ’SecurityGroupIds’ (list[str]): List of security group ids.

  • enable_network_isolation (bool) – Specifies whether container will run in network isolation mode. Network isolation mode restricts the container access to outside networks (such as the internet). The container does not make any inbound or outbound network calls. If True, a channel named “code” will be created for any user entry script for inference. Also known as Internet-free mode. If not specified, this setting is taken from the estimator’s current configuration.

  • model_name (str) – Name to use for creating an Amazon SageMaker model. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

update_profiler(rules=None, system_monitor_interval_millis=None, s3_output_path=None, framework_profile_params=None, disable_framework_metrics=False)

Update training jobs to enable profiling.

This method updates the profiler_config parameter and initiates Debugger built-in rules for profiling.

Parameters
  • rules (list[ProfilerRule]) – A list of ProfilerRule objects to define rules for continuous analysis with SageMaker Debugger. Currently, you can only add new profiler rules during the training job. (default: None)

  • s3_output_path (str) – The location in S3 to store the output. If profiler is enabled once, s3_output_path cannot be changed. (default: None)

  • system_monitor_interval_millis (int) – How often profiling system metrics are collected; Unit: Milliseconds (default: None)

  • framework_profile_params (FrameworkProfile) – A parameter object for framework metrics profiling. Configure it using the FrameworkProfile class. To use the default framework profile parameters, pass FrameworkProfile(). For more information about the default values, see FrameworkProfile. (default: None)

  • disable_framework_metrics (bool) – Specify whether to disable all the framework metrics. This won’t update system metrics and the Debugger built-in rules for monitoring. To stop both monitoring and profiling, use the desable_profiling method. (default: False)

Attention

Updating the profiling configuration for TensorFlow dataloader profiling is currently not available. If you started a TensorFlow training job only with monitoring and want to enable profiling while the training job is running, the dataloader profiling cannot be updated.

uploaded_code: Optional[UploadedCode]
class sagemaker.estimator.Framework(entry_point, source_dir=None, hyperparameters=None, container_log_level=20, code_location=None, image_uri=None, dependencies=None, enable_network_isolation=None, git_config=None, checkpoint_s3_uri=None, checkpoint_local_path=None, enable_sagemaker_metrics=None, **kwargs)

Bases: EstimatorBase

Base class that cannot be instantiated directly.

Subclasses define functionality pertaining to specific ML frameworks, such as training/deployment images and predictor instances.

Base class initializer.

Subclasses which override __init__ should invoke super().

Parameters
  • entry_point (str or PipelineVariable) –

    Path (absolute or relative) to the local Python source file which should be executed as the entry point to training. If source_dir is specified, then entry_point must point to a file located at the root of source_dir. If ‘git_config’ is provided, ‘entry_point’ should be a relative location to the Python source file in the Git repo.

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- train.py
    >>>         |----- test.py
    

    You can assign entry_point=’src/train.py’.

  • source_dir (str or PipelineVariable) –

    Path (absolute, relative or an S3 URI) to a directory with any other training source code dependencies aside from the entry point file (default: None). If source_dir is an S3 URI, it must point to a tar.gz file. Structure within this directory are preserved when training on Amazon SageMaker. If ‘git_config’ is provided, ‘source_dir’ should be a relative location to a directory in the Git repo.

    Example

    With the following GitHub repo directory structure:

    >>> |----- README.md
    >>> |----- src
    >>>         |----- train.py
    >>>         |----- test.py
    

    and you need ‘train.py’ as entry point and ‘test.py’ as training source code as well, you can assign entry_point=’train.py’, source_dir=’src’.

  • hyperparameters (dict[str, str] or dict[str, PipelineVariable]) –

    Hyperparameters that will be used for training (default: None). The hyperparameters are made accessible as a dict[str, str] to the training code on SageMaker. For convenience, this accepts other types for keys and values, but str() will be called to convert them before training.

    Caution

    You must not include any security-sensitive information, such as account access IDs, secrets, and tokens, in the dictionary for configuring hyperparameters. SageMaker rejects the training job request and returns an validation error for detected credentials, if such user input is found.

  • container_log_level (int or PipelineVariable) – Log level to use within the container (default: logging.INFO). Valid values are defined in the Python logging module.

  • code_location (str) – The S3 prefix URI where custom code will be uploaded (default: None) - don’t include a trailing slash since a string prepended with a “/” is appended to code_location. The code file uploaded to S3 is ‘code_location/job-name/source/sourcedir.tar.gz’. If not specified, the default code location is s3://output_bucket/job-name/.

  • image_uri (str or PipelineVariable) – An alternate image name to use instead of the official Sagemaker image for the framework. This is useful to run one of the Sagemaker supported frameworks with an image containing custom dependencies.

  • dependencies (list[str]) –

    A list of paths to directories (absolute or relative) with any additional libraries that will be exported to the container (default: []). The library folders will be copied to SageMaker in the same folder where the entrypoint is copied. If ‘git_config’ is provided, ‘dependencies’ should be a list of relative locations to directories with any additional libraries needed in the Git repo.

    Example

    The following call

    >>> Estimator(entry_point='train.py',
    ...           dependencies=['my/libs/common', 'virtual-env'])
    

    results in the following inside the container:

    >>> $ ls
    
    >>> opt/ml/code
    >>>     |------ train.py
    >>>     |------ common
    >>>     |------ virtual-env
    

    This is not supported with “local code” in Local Mode.

  • enable_network_isolation (bool or PipelineVariable) – Specifies whether container will run in network isolation mode. Network isolation mode restricts the container access to outside networks (such as the internet). The container does not make any inbound or outbound network calls. If True, a channel named “code” will be created for any user entry script for training. The user entry script, files in source_dir (if specified), and dependencies will be uploaded in a tar to S3. Also known as internet-free mode (default: False).

  • git_config (dict[str, str]) –

    Git configurations used for cloning files, including repo, branch, commit, 2FA_enabled, username, password and token. The repo field is required. All other fields are optional. repo specifies the Git repository where your training script is stored. If you don’t provide branch, the default value ‘master’ is used. If you don’t provide commit, the latest commit in the specified branch is used. .. admonition:: Example

    The following config:

    >>> git_config = {'repo': 'https://github.com/aws/sagemaker-python-sdk.git',
    >>>               'branch': 'test-branch-git-config',
    >>>               'commit': '329bfcf884482002c05ff7f44f62599ebc9f445a'}
    

    results in cloning the repo specified in ‘repo’, then checkout the ‘master’ branch, and checkout the specified commit.

    2FA_enabled, username, password and token are used for authentication. For GitHub (or other Git) accounts, set 2FA_enabled to ‘True’ if two-factor authentication is enabled for the account, otherwise set it to ‘False’. If you do not provide a value for 2FA_enabled, a default value of ‘False’ is used. CodeCommit does not support two-factor authentication, so do not provide “2FA_enabled” with CodeCommit repositories.

    For GitHub and other Git repos, when SSH URLs are provided, it doesn’t matter whether 2FA is enabled or disabled; you should either have no passphrase for the SSH key pairs, or have the ssh-agent configured so that you will not be prompted for SSH passphrase when you do ‘git clone’ command with SSH URLs. When HTTPS URLs are provided: if 2FA is disabled, then either token or username+password will be used for authentication if provided (token prioritized); if 2FA is enabled, only token will be used for authentication if provided. If required authentication info is not provided, python SDK will try to use local credentials storage to authenticate. If that fails either, an error message will be thrown.

    For CodeCommit repos, 2FA is not supported, so ‘2FA_enabled’ should not be provided. There is no token in CodeCommit, so ‘token’ should not be provided too. When ‘repo’ is an SSH URL, the requirements are the same as GitHub-like repos. When ‘repo’ is an HTTPS URL, username+password will be used for authentication if they are provided; otherwise, python SDK will try to use either CodeCommit credential helper or local credential storage for authentication.

  • checkpoint_s3_uri (str or PipelineVariable) – The S3 URI in which to persist checkpoints that the algorithm persists (if any) during training. (default: None).

  • checkpoint_local_path (str or PipelineVariable) – The local path that the algorithm writes its checkpoints to. SageMaker will persist all files under this path to checkpoint_s3_uri continually during training. On job startup the reverse happens - data from the s3 location is downloaded to this path before the algorithm is started. If the path is unset then SageMaker assumes the checkpoints will be provided under /opt/ml/checkpoints/. (default: None).

  • enable_sagemaker_metrics (bool or PipelineVariable) – enable SageMaker Metrics Time Series. For more information see: https://docs.aws.amazon.com/sagemaker/latest/dg/API_AlgorithmSpecification.html#SageMaker-Type-AlgorithmSpecification-EnableSageMakerMetricsTimeSeries (default: None).

  • **kwargs – Additional kwargs passed to the EstimatorBase constructor.

Tip

You can find additional parameters for initializing this class at EstimatorBase.

UNSUPPORTED_DLC_IMAGE_FOR_SM_PARALLELISM = ('2.0.1-gpu-py310-cu121',)
uploaded_code: Optional[UploadedCode]
set_hyperparameters(**kwargs)

Escapes the dict argument as JSON, updates the private hyperparameter attribute.

hyperparameters()

Returns the hyperparameters as a dictionary to use for training.

The fit() method, which trains the model, calls this method to find the hyperparameters.

Returns

The hyperparameters.

Return type

dict[str, str]

training_image_uri(region=None)

Return the Docker image to use for training.

The fit() method, which does the model training, calls this method to find the image to use for model training.

Parameters
  • region (str) – Optional. The AWS Region to use for image URI. Default: AWS Region

  • session. (associated with the SageMaker) –

Returns

The URI of the Docker image.

Return type

str

classmethod attach(training_job_name, sagemaker_session=None, model_channel_name='model')

Attach to an existing training job.

Create an Estimator bound to an existing training job, each subclass is responsible to implement _prepare_init_params_from_job_description() as this method delegates the actual conversion of a training job description to the arguments that the class constructor expects. After attaching, if the training job has a Complete status, it can be deploy() ed to create a SageMaker Endpoint and return a Predictor.

If the training job is in progress, attach will block until the training job completes, but logs of the training job will not display. To see the logs content, please call logs()

Examples

>>> my_estimator.fit(wait=False)
>>> training_job_name = my_estimator.latest_training_job.name
Later on:
>>> attached_estimator = Estimator.attach(training_job_name)
>>> attached_estimator.logs()
>>> attached_estimator.deploy()
Parameters
  • training_job_name (str) – The name of the training job to attach to.

  • sagemaker_session (sagemaker.session.Session) – Session object which manages interactions with Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one using the default AWS configuration chain.

  • model_channel_name (str) – Name of the channel where pre-trained model data will be downloaded (default: ‘model’). If no channel with the same name exists in the training job, this option will be ignored.

Returns

Instance of the calling Estimator Class with the attached training job.

transformer(instance_count, instance_type, strategy=None, assemble_with=None, output_path=None, output_kms_key=None, accept=None, env=None, max_concurrent_transforms=None, max_payload=None, tags=None, role=None, model_server_workers=None, volume_kms_key=None, entry_point=None, vpc_config_override='VPC_CONFIG_DEFAULT', enable_network_isolation=None, model_name=None)

Return a Transformer that uses a SageMaker Model based on the training job.

It reuses the SageMaker Session and base job name used by the Estimator.

Parameters
  • instance_count (int) – Number of EC2 instances to use.

  • instance_type (str) – Type of EC2 instance to use, for example, ‘ml.c4.xlarge’.

  • strategy (str) – The strategy used to decide how to batch records in a single request (default: None). Valid values: ‘MultiRecord’ and ‘SingleRecord’.

  • assemble_with (str) – How the output is assembled (default: None). Valid values: ‘Line’ or ‘None’.

  • output_path (str) – S3 location for saving the transform result. If not specified, results are stored to a default bucket.

  • output_kms_key (str) – Optional. KMS key ID for encrypting the transform output (default: None).

  • accept (str) – The accept header passed by the client to the inference endpoint. If it is supported by the endpoint, it will be the format of the batch transform output.

  • env (dict) – Environment variables to be set for use during the transform job (default: None).

  • max_concurrent_transforms (int) – The maximum number of HTTP requests to be made to each individual transform container at one time.

  • max_payload (int) – Maximum size of the payload in a single HTTP request to the container in MB.

  • tags (Optional[Tags]) – Tags for labeling a transform job. If none specified, then the tags used for the training job are used for the transform job.

  • role (str) – The ExecutionRoleArn IAM Role ARN for the Model, which is also used during transform jobs. If not specified, the role from the Estimator will be used.

  • model_server_workers (int) – Optional. The number of worker processes used by the inference server. If None, server will use one worker per vCPU.

  • volume_kms_key (str) – Optional. KMS key ID for encrypting the volume attached to the ML compute instance (default: None).

  • entry_point (str) – Path (absolute or relative) to the local Python source file which should be executed as the entry point to training. If source_dir is specified, then entry_point must point to a file located at the root of source_dir. If not specified, the training entry point is used.

  • vpc_config_override (dict[str, list[str]]) –

    Optional override for the VpcConfig set on the model. Default: use subnets and security groups from this Estimator.

    • ’Subnets’ (list[str]): List of subnet ids.

    • ’SecurityGroupIds’ (list[str]): List of security group ids.

  • enable_network_isolation (bool) – Specifies whether container will run in network isolation mode. Network isolation mode restricts the container access to outside networks (such as the internet). The container does not make any inbound or outbound network calls. If True, a channel named “code” will be created for any user entry script for inference. Also known as Internet-free mode. If not specified, this setting is taken from the estimator’s current configuration.

  • model_name (str) – Name to use for creating an Amazon SageMaker model. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

Returns

a Transformer object that can be used to start a

SageMaker Batch Transform job.

Return type

sagemaker.transformer.Transformer

CONTAINER_CODE_CHANNEL_SOURCEDIR_PATH = '/opt/ml/input/data/code/sourcedir.tar.gz'
INSTANCE_TYPE = 'sagemaker_instance_type'
JOB_CLASS_NAME = 'training-job'
LAUNCH_MPI_ENV_NAME = 'sagemaker_mpi_enabled'
LAUNCH_MWMS_ENV_NAME = 'sagemaker_multi_worker_mirrored_strategy_enabled'
LAUNCH_PS_ENV_NAME = 'sagemaker_parameter_server_enabled'
LAUNCH_PT_XLA_ENV_NAME = 'sagemaker_pytorch_xla_multi_worker_enabled'
LAUNCH_SM_DDP_ENV_NAME = 'sagemaker_distributed_dataparallel_enabled'
MPI_CUSTOM_MPI_OPTIONS = 'sagemaker_mpi_custom_mpi_options'
MPI_NUM_PROCESSES_PER_HOST = 'sagemaker_mpi_num_of_processes_per_host'
SM_DDP_CUSTOM_MPI_OPTIONS = 'sagemaker_distributed_dataparallel_custom_mpi_options'
compile_model(target_instance_family, input_shape, output_path, framework=None, framework_version=None, compile_max_run=900, tags=None, target_platform_os=None, target_platform_arch=None, target_platform_accelerator=None, compiler_options=None, **kwargs)

Compile a Neo model using the input model.

Parameters
Returns

A SageMaker Model object. See Model() for full details.

Return type

sagemaker.model.Model

abstract create_model(**kwargs)

Create a SageMaker Model object that can be deployed to an Endpoint.

Parameters

**kwargs – Keyword arguments used by the implemented method for creating the Model.

Returns

A SageMaker Model object. See Model() for full details.

Return type

sagemaker.model.Model

delete_endpoint(**kwargs)
deploy(initial_instance_count=None, instance_type=None, serializer=None, deserializer=None, accelerator_type=None, endpoint_name=None, use_compiled_model=False, wait=True, model_name=None, kms_key=None, data_capture_config=None, tags=None, serverless_inference_config=None, async_inference_config=None, volume_size=None, model_data_download_timeout=None, container_startup_health_check_timeout=None, inference_recommendation_id=None, explainer_config=None, **kwargs)

Deploy the trained model to an Amazon SageMaker endpoint.

And then return sagemaker.Predictor object.

More information: http://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html

Parameters
  • initial_instance_count (int) – The initial number of instances to run in the Endpoint created from this Model. If not using serverless inference, then it need to be a number larger or equals to 1 (default: None)

  • instance_type (str) – The EC2 instance type to deploy this Model to. For example, ‘ml.p2.xlarge’, or ‘local’ for local mode. If not using serverless inference, then it is required to deploy a model. (default: None)

  • serializer (BaseSerializer) – A serializer object, used to encode data for an inference endpoint (default: None). If serializer is not None, then serializer will override the default serializer. The default serializer is set by the predictor_cls.

  • deserializer (BaseDeserializer) – A deserializer object, used to decode data from an inference endpoint (default: None). If deserializer is not None, then deserializer will override the default deserializer. The default deserializer is set by the predictor_cls.

  • accelerator_type (str) – Type of Elastic Inference accelerator to attach to an endpoint for model loading and inference, for example, ‘ml.eia1.medium’. If not specified, no Elastic Inference accelerator will be attached to the endpoint. For more information: https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html

  • endpoint_name (str) – Name to use for creating an Amazon SageMaker endpoint. If not specified, the name of the training job is used.

  • use_compiled_model (bool) – Flag to select whether to use compiled (optimized) model. Default: False.

  • wait (bool) – Whether the call should wait until the deployment of model completes (default: True).

  • model_name (str) – Name to use for creating an Amazon SageMaker model. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

  • kms_key (str) – The ARN of the KMS key that is used to encrypt the data on the storage volume attached to the instance hosting the endpoint.

  • data_capture_config (sagemaker.model_monitor.DataCaptureConfig) – Specifies configuration related to Endpoint data capture for use with Amazon SageMaker Model Monitoring. Default: None.

  • async_inference_config (sagemaker.model_monitor.AsyncInferenceConfig) – Specifies configuration related to async inference. Use this configuration when trying to create async endpoint and make async inference. If empty config object passed through, will use default config to deploy async endpoint. Deploy a real-time endpoint if it’s None. (default: None)

  • serverless_inference_config (sagemaker.serverless.ServerlessInferenceConfig) – Specifies configuration related to serverless endpoint. Use this configuration when trying to create serverless endpoint and make serverless inference. If empty object passed through, will use pre-defined values in ServerlessInferenceConfig class to deploy serverless endpoint. Deploy an instance based endpoint if it’s None. (default: None)

  • tags (Optional[Tags]) – Optional. Tags to attach to this specific endpoint. Example: >>> tags = {‘tagname’, ‘tagvalue’} Or >>> tags = [{‘Key’: ‘tagname’, ‘Value’: ‘tagvalue’}] For more information about tags, see https://boto3.amazonaws.com/v1/documentation /api/latest/reference/services/sagemaker.html#SageMaker.Client.add_tags

  • volume_size (int) – The size, in GB, of the ML storage volume attached to individual inference instance associated with the production variant. Currenly only Amazon EBS gp2 storage volumes are supported.

  • model_data_download_timeout (int) – The timeout value, in seconds, to download and extract model data from Amazon S3 to the individual inference instance associated with this production variant.

  • container_startup_health_check_timeout (int) – The timeout value, in seconds, for your inference container to pass health check by SageMaker Hosting. For more information about health check see: https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code.html#your-algorithms-inference-algo-ping-requests

  • inference_recommendation_id (str) – The recommendation id which specifies the recommendation you picked from inference recommendation job results and would like to deploy the model and endpoint with recommended parameters.

  • explainer_config (sagemaker.explainer.ExplainerConfig) – Specifies online explainability configuration for use with Amazon SageMaker Clarify. (default: None)

  • **kwargs – Passed to invocation of create_model(). Implementations may customize create_model() to accept **kwargs to customize model creation during deploy. For more, see the implementation docs.

Returns

A predictor that provides a predict() method,

which can be used to send requests to the Amazon SageMaker endpoint and obtain inferences.

Return type

sagemaker.predictor.Predictor

disable_profiling()

Update the current training job in progress to disable profiling.

Debugger stops collecting the system and framework metrics and turns off the Debugger built-in monitoring and profiling rules.

disable_remote_debug()

Disable remote debug for a training job.

enable_default_profiling()

Update training job to enable Debugger monitoring.

This method enables Debugger monitoring with the default profiler_config parameter to collect system metrics and the default built-in profiler_report rule. Framework metrics won’t be saved. To update training job to emit framework metrics, you can use update_profiler method and specify the framework metrics you want to enable.

This method is callable when the training job is in progress while Debugger monitoring is disabled.

enable_network_isolation()

Return True if this Estimator will need network isolation to run.

Returns

Whether this Estimator needs network isolation or not.

Return type

bool

enable_remote_debug()

Enable remote debug for a training job.

fit(inputs=None, wait=True, logs='All', job_name=None, experiment_config=None)

Train a model using the input training dataset.

The API calls the Amazon SageMaker CreateTrainingJob API to start model training. The API uses configuration you provided to create the estimator and the specified input training data to send the CreatingTrainingJob request to Amazon SageMaker.

This is a synchronous operation. After the model training successfully completes, you can call the deploy() method to host the model using the Amazon SageMaker hosting services.

Parameters
  • or (inputs (str or dict or sagemaker.inputs.TrainingInput) –

    sagemaker.inputs.FileSystemInput): Information about the training data. This can be one of four types:

    • (str) the S3 location where training data is saved, or a file:// path in

      local mode.

    • (dict[str, str] or dict[str, sagemaker.inputs.TrainingInput] or

      dict[str, sagemaker.inputs.FileSystemInput]) If using multiple channels for training data, you can specify a dict mapping channel names to strings or TrainingInput() objects or FileSystemInput() objects.

    • (sagemaker.inputs.TrainingInput) - channel configuration for S3 data sources

      that can provide additional information as well as the path to the training dataset. See sagemaker.inputs.TrainingInput() for full details.

    • (sagemaker.inputs.FileSystemInput) - channel configuration for

      a file system data source that can provide additional information as well as the path to the training dataset.

  • wait (bool) – Whether the call should wait until the job completes (default: True).

  • logs ([str]) – A list of strings specifying which logs to print. Acceptable strings are “All”, “None”, “Training”, or “Rules”. To maintain backwards compatibility, boolean values are also accepted and converted to strings. Only meaningful when wait is True.

  • job_name (str) – Training job name. If not specified, the estimator generates a default job name based on the training image name and current timestamp.

  • experiment_config (dict[str, str]) – Experiment management configuration. Optionally, the dict can contain four keys: ‘ExperimentName’, ‘TrialName’, ‘TrialComponentDisplayName’ and ‘RunName’.. The behavior of setting these keys is as follows: * If ExperimentName is supplied but TrialName is not a Trial will be automatically created and the job’s Trial Component associated with the Trial. * If TrialName is supplied and the Trial already exists the job’s Trial Component will be associated with the Trial. * If both ExperimentName and TrialName are not supplied the trial component will be unassociated. * TrialComponentDisplayName is used for display in Studio. * Both ExperimentName and TrialName will be ignored if the Estimator instance is built with PipelineSession. However, the value of TrialComponentDisplayName is honored for display in Studio.

  • inputs (Optional[Union[str, Dict, TrainingInput, FileSystemInput]]) –

Returns

None or pipeline step arguments in case the Estimator instance is built with PipelineSession

get_app_url(app_type, open_in_default_web_browser=True, create_presigned_domain_url=False, domain_id=None, user_profile_name=None, optional_create_presigned_url_kwargs=None)

Generate a URL to help access the specified app hosted in Amazon SageMaker Studio.

Parameters
  • app_type (str or SupportedInteractiveAppTypes) – Required. The app type available in SageMaker Studio to return a URL to.

  • open_in_default_web_browser (bool) – Optional. When True, the URL will attempt to be opened in the environment’s default web browser. Otherwise, the resulting URL will be returned by this function. Default: True

  • create_presigned_domain_url (bool) – Optional. Determines whether a presigned domain URL should be generated instead of an unsigned URL. This only applies when called from outside of a SageMaker Studio environment. If this is set to True inside of a SageMaker Studio environment, it will be ignored. Default: False

  • domain_id (str) – Optional. The AWS Studio domain that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • user_profile_name (str) – Optional. The AWS Studio user profile that the resulting app will use. If code is executing in a Studio environment and this was not supplied, this will be automatically detected. If not supplied and running in a non-Studio environment, it is up to the derived class on how to handle that, but in general, a redirect to a landing page can be expected. Default: None

  • optional_create_presigned_url_kwargs (dict) – Optional. This parameter should be passed when a user outside of Studio wants a presigned URL to the TensorBoard application and wants to modify the optional parameters of the create_presigned_domain_url call. Default: None

Returns

A URL for the requested app in SageMaker Studio.

Return type

str

get_remote_debug_config()

dict: Return the configuration of RemoteDebug

get_session_chaining_config()

dict: Return the configuration of SessionChaining

get_vpc_config(vpc_config_override='VPC_CONFIG_DEFAULT')

Returns VpcConfig dict either from this Estimator’s subnets and security groups.

Or else validate and return an optional override value.

Parameters

vpc_config_override

latest_job_debugger_artifacts_path()

Gets the path to the DebuggerHookConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_profiler_artifacts_path()

Gets the path to the profiling output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

latest_job_tensorboard_artifacts_path()

Gets the path to the TensorBoardOutputConfig output artifacts.

Returns

An S3 path to the output artifacts.

Return type

str

logs()

Display the logs for Estimator’s training job.

If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from.

property model_data

The model location in S3. Only set if Estimator has been fit().

Type

Str or dict

prepare_workflow_for_training(job_name=None)

Calls _prepare_for_training. Used when setting up a workflow.

Parameters

job_name (str) – Name of the training job to be created. If not specified, one is generated, using the base name given to the constructor if applicable.

register(content_types=None, response_types=None, inference_instances=None, transform_instances=None, image_uri=None, model_package_name=None, model_package_group_name=None, model_metrics=None, metadata_properties=None, marketplace_cert=False, approval_status=None, description=None, compile_model_family=None, model_name=None, drift_check_baselines=None, customer_metadata_properties=None, domain=None, sample_payload_url=None, task=None, framework=None, framework_version=None, nearest_model_name=None, data_input_configuration=None, skip_model_validation=None, source_uri=None, model_card=None, **kwargs)

Creates a model package for creating SageMaker models or listing on Marketplace.

Parameters
  • content_types (list) – The supported MIME types for the input data.

  • response_types (list) – The supported MIME types for the output data.

  • inference_instances (list) – A list of the instance types that are used to generate inferences in real-time (default: None).

  • transform_instances (list) – A list of the instance types on which a transformation job can be run or on which an endpoint can be deployed (default: None).

  • image_uri (str) – The container image uri for Model Package, if not specified, Estimator’s training container image will be used (default: None).

  • model_package_name (str) – Model Package name, exclusive to model_package_group_name, using model_package_name makes the Model Package un-versioned (default: None).

  • model_package_group_name (str) – Model Package Group name, exclusive to model_package_name, using model_package_group_name makes the Model Package versioned (default: None).

  • model_metrics (ModelMetrics) – ModelMetrics object (default: None).

  • metadata_properties (MetadataProperties) – MetadataProperties (default: None).

  • marketplace_cert (bool) – A boolean value indicating if the Model Package is certified for AWS Marketplace (default: False).

  • approval_status (str) – Model Approval Status, values can be “Approved”, “Rejected”, or “PendingManualApproval” (default: “PendingManualApproval”).

  • description (str) – Model Package description (default: None).

  • compile_model_family (str) – Instance family for compiled model, if specified, a compiled model will be used (default: None).

  • model_name (str) – User defined model name (default: None).

  • drift_check_baselines (DriftCheckBaselines) – DriftCheckBaselines object (default: None).

  • customer_metadata_properties (dict[str, str]) – A dictionary of key-value paired metadata properties (default: None).

  • domain (str) – Domain values can be “COMPUTER_VISION”, “NATURAL_LANGUAGE_PROCESSING”, “MACHINE_LEARNING” (default: None).

  • sample_payload_url (str) – The S3 path where the sample payload is stored (default: None).

  • task (str) – Task values which are supported by Inference Recommender are “FILL_MASK”, “IMAGE_CLASSIFICATION”, “OBJECT_DETECTION”, “TEXT_GENERATION”, “IMAGE_SEGMENTATION”, “CLASSIFICATION”, “REGRESSION”, “OTHER” (default: None).

  • framework (str) – Machine learning framework of the model package container image (default: None).

  • framework_version (str) – Framework version of the Model Package Container Image (default: None).

  • nearest_model_name (str) – Name of a pre-trained machine learning benchmarked by Amazon SageMaker Inference Recommender (default: None).

  • data_input_configuration (str) – Input object for the model (default: None).

  • skip_model_validation (str) – Indicates if you want to skip model validation. Values can be “All” or “None” (default: None).

  • source_uri (str) – The URI of the source for the model package (default: None).

  • model_card (ModeCard or ModelPackageModelCard) – document contains qualitative and quantitative information about a model (default: None).

  • **kwargs – Passed to invocation of create_model(). Implementations may customize create_model() to accept **kwargs to customize model creation during deploy. For more, see the implementation docs.

Returns

A string of SageMaker Model Package ARN.

Return type

str

property training_job_analytics

Return a TrainingJobAnalytics object for the current training job.

update_profiler(rules=None, system_monitor_interval_millis=None, s3_output_path=None, framework_profile_params=None, disable_framework_metrics=False)

Update training jobs to enable profiling.

This method updates the profiler_config parameter and initiates Debugger built-in rules for profiling.

Parameters
  • rules (list[ProfilerRule]) – A list of ProfilerRule objects to define rules for continuous analysis with SageMaker Debugger. Currently, you can only add new profiler rules during the training job. (default: None)

  • s3_output_path (str) – The location in S3 to store the output. If profiler is enabled once, s3_output_path cannot be changed. (default: None)

  • system_monitor_interval_millis (int) – How often profiling system metrics are collected; Unit: Milliseconds (default: None)

  • framework_profile_params (FrameworkProfile) – A parameter object for framework metrics profiling. Configure it using the FrameworkProfile class. To use the default framework profile parameters, pass FrameworkProfile(). For more information about the default values, see FrameworkProfile. (default: None)

  • disable_framework_metrics (bool) – Specify whether to disable all the framework metrics. This won’t update system metrics and the Debugger built-in rules for monitoring. To stop both monitoring and profiling, use the desable_profiling method. (default: False)

Attention

Updating the profiling configuration for TensorFlow dataloader profiling is currently not available. If you started a TensorFlow training job only with monitoring and want to enable profiling while the training job is running, the dataloader profiling cannot be updated.