RLEstimator: RLEstimator Class

RLEstimatorR Documentation

RLEstimator Class

Description

Handle end-to-end training and deployment of custom RLEstimator code.

Super classes

sagemaker.mlcore::EstimatorBase -> sagemaker.mlcore::Framework -> RLEstimator

Public fields

COACH_LATEST_VERSION_TF

latest version of toolkit coach for tensorflow

COACH_LATEST_VERSION_MXNET

latest version of toolkit coach for mxnet

RAY_LATEST_VERSION

latest version of toolkit ray

.module

mimic python module

Methods

Public methods

Inherited methods

Method new()

Creates an RLEstimator for managed Reinforcement Learning (RL). It will execute an RLEstimator script within a SageMaker Training Job. The managed RL environment is an Amazon-built Docker container that executes functions defined in the supplied “entry_point“ Python script. Training is started by calling :meth:'~sagemaker.amazon.estimator.Framework.fit' on this Estimator. After training is complete, calling :meth:'~sagemaker.amazon.estimator.Framework.deploy' creates a hosted SageMaker endpoint and based on the specified framework returns an :class:'~sagemaker.amazon.mxnet.model.MXNetPredictor' or :class:'~sagemaker.amazon.tensorflow.model.TensorFlowPredictor' instance that can be used to perform inference against the hosted model. Technical documentation on preparing RLEstimator scripts for SageMaker training and using the RLEstimator is available on the project homepage: https://github.com/aws/sagemaker-python-sdk

Usage
RLEstimator$new(
  entry_point,
  toolkit = NULL,
  toolkit_version = NULL,
  framework = NULL,
  source_dir = NULL,
  hyperparameters = NULL,
  image_uri = NULL,
  metric_definitions = NULL,
  ...
)
Arguments
entry_point

(str): Path (absolute or relative) to the 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“.

toolkit

(sagemaker.rl.RLToolkit): RL toolkit you want to use for executing your model training code.

toolkit_version

(str): RL toolkit version you want to be use for executing your model training code.

framework

(sagemaker.rl.RLFramework): Framework (MXNet or TensorFlow) you want to be used as a toolkit backed for reinforcement learning training.

source_dir

(str): Path (absolute, relative or an S3 URI) to a directory with any other training source code dependencies aside from the entry point file (default: NULL). 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.

hyperparameters

(dict): Hyperparameters that will be used for training (default: NULL). 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.

image_uri

(str): An ECR url. If specified, the estimator will use this image for training and hosting, instead of selecting the appropriate SageMaker official image based on framework_version and py_version. Example: 123.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0

metric_definitions

(list[dict]): 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.

...

: Additional kwargs passed to the :class:'~sagemaker.estimator.Framework' constructor. .. tip:: You can find additional parameters for initializing this class at :class:'~sagemaker.estimator.Framework' and :class:'~sagemaker.estimator.EstimatorBase'.


Method create_model()

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

Usage
RLEstimator$create_model(
  role = NULL,
  vpc_config_override = "VPC_CONFIG_DEFAULT",
  entry_point = NULL,
  source_dir = NULL,
  dependencies = NULL,
  ...
)
Arguments
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.

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.

entry_point

(str): Path (absolute or relative) to the Python source file which should be executed as the entry point for MXNet hosting (default: self.entry_point). If “source_dir“ is specified, then “entry_point“ must point to a file located at the root of “source_dir“.

source_dir

(str): Path (absolute or relative) to a directory with any other training source code dependencies aside from the entry point file (default: self.source_dir). Structure within this directory are preserved when hosting on Amazon SageMaker.

dependencies

(list[str]): A list of paths to directories (absolute or relative) with any additional libraries that will be exported to the container (default: self.dependencies). The library folders will be copied to SageMaker in the same folder where the entry_point is copied. If the “'source_dir“' points to S3, code will be uploaded and the S3 location will be used instead. This is not supported with "local code" in Local Mode.

...

: Additional kwargs passed to the :class:'~sagemaker.model.FrameworkModel' constructor.

Returns

sagemaker.model.FrameworkModel: Depending on input parameters returns one of the following: * :class:'~sagemaker.model.FrameworkModel' - if “image_uri“ is specified on the estimator; * :class:‘~sagemaker.mxnet.MXNetModel' - if “image_uri“ isn’t specified and MXNet is used as the RL backend; * :class:‘~sagemaker.tensorflow.model.TensorFlowModel' - if “image_uri“ isn’t specified and TensorFlow is used as the RL backend.


Method training_image_uri()

Return the Docker image to use for training. The :meth:'~sagemaker.estimator.EstimatorBase.fit' method, which does the model training, calls this method to find the image to use for model training.

Usage
RLEstimator$training_image_uri()
Returns

str: The URI of the Docker image.


Method hyperparameters()

Return hyperparameters used by your custom TensorFlow code during model training.

Usage
RLEstimator$hyperparameters()

Method default_metric_definitions()

Provides default metric definitions based on provided toolkit.

Usage
RLEstimator$default_metric_definitions(toolkit)
Arguments
toolkit

(sagemaker.rl.RLToolkit): RL Toolkit to be used for training.

Returns

list: metric definitions


Method clone()

The objects of this class are cloneable with this method.

Usage
RLEstimator$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


DyfanJones/sagemaker-r-mlframework documentation built on March 18, 2022, 7:41 a.m.