AmazonAlgorithmEstimatorBase: AmazonAlgorithmEstimatorBase Class

AmazonAlgorithmEstimatorBaseR Documentation

AmazonAlgorithmEstimatorBase Class

Description

Base class for Amazon first-party Estimator implementations. This class isn't intended to be instantiated directly.

Super class

sagemaker.mlcore::EstimatorBase -> AmazonAlgorithmEstimatorBase

Public fields

repo_name

The repo name for the account

repo_version

Version fo repo to call

.module

mimic python module

Active bindings

data_location

The s3 prefix to upload RecordSet objects to, expressed as an S3 url

feature_dim

Hyperparameter class for feature_dim

mini_batch_size

Hyperparameter class for mini_batch_size

Methods

Public methods

Inherited methods

Method new()

Initialize an AmazonAlgorithmEstimatorBase.

Usage
AmazonAlgorithmEstimatorBase$new(
  role,
  instance_count,
  instance_type,
  data_location = NULL,
  enable_network_isolation = FALSE,
  ...
)
Arguments
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): Number of Amazon EC2 instances to use for training.

instance_type

(str): Type of EC2 instance to use for training, for example, 'ml.c4.xlarge'.

data_location

(str or None): The s3 prefix to upload RecordSet objects to, expressed as an S3 url. For example "s3://example-bucket/some-key-prefix/". Objects will be saved in a unique sub-directory of the specified location. If None, a default data location will be used.

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). Also known as internet-free mode (default: “False“).

...

: Additional parameters passed to :class:'~sagemaker.estimator.EstimatorBase'.


Method training_image_uri()

Return algorithm image URI for the given AWS region, repository name, and repository version

Usage
AmazonAlgorithmEstimatorBase$training_image_uri()

Method hyperparameters()

Return all non-None “hyperparameter“ values on “obj“ as a “dict[str,str].“

Usage
AmazonAlgorithmEstimatorBase$hyperparameters()

Method prepare_workflow_for_training()

Calls _prepare_for_training. Used when setting up a workflow.

Usage
AmazonAlgorithmEstimatorBase$prepare_workflow_for_training(
  records = NULL,
  mini_batch_size = NULL,
  job_name = NULL
)
Arguments
records

(:class:'~RecordSet'): The records to train this “Estimator“ on.

mini_batch_size

(int or None): The size of each mini-batch to use when training. If “None“, a default value will be used.

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.


Method fit()

Fit this Estimator on serialized Record objects, stored in S3. “records“ should be an instance of :class:'~RecordSet'. This defines a collection of S3 data files to train this “Estimator“ on. Training data is expected to be encoded as dense or sparse vectors in the "values" feature on each Record. If the data is labeled, the label is expected to be encoded as a list of scalas in the "values" feature of the Record label. More information on the Amazon Record format is available at: https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html See :meth:'~AmazonAlgorithmEstimatorBase.record_set' to construct a “RecordSet“ object from :class:'~numpy.ndarray' arrays.

Usage
AmazonAlgorithmEstimatorBase$fit(
  records,
  mini_batch_size = NULL,
  wait = TRUE,
  logs = TRUE,
  job_name = NULL,
  experiment_config = NULL
)
Arguments
records

(:class:'~RecordSet'): The records to train this “Estimator“ on

mini_batch_size

(int or None): The size of each mini-batch to use when training. If “None“, a default value will be used.

wait

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

logs

(bool): Whether to show the logs produced by the job. Only meaningful when wait is True (default: 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. Dictionary contains three optional keys, 'ExperimentName', 'TrialName', and 'TrialComponentName' (default: “None“).


Method record_set()

Build a :class:'~RecordSet' from a numpy :class:'~ndarray' matrix and label vector. For the 2D “ndarray“ “train“, each row is converted to a :class:'~Record' object. The vector is stored in the "values" entry of the “features“ property of each Record. If “labels“ is not None, each corresponding label is assigned to the "values" entry of the “labels“ property of each Record. The collection of “Record“ objects are protobuf serialized and uploaded to new S3 locations. A manifest file is generated containing the list of objects created and also stored in S3. The number of S3 objects created is controlled by the “instance_count“ property on this Estimator. One S3 object is created per training instance.

Usage
AmazonAlgorithmEstimatorBase$record_set(
  train,
  labels = NULL,
  channel = "train",
  encrypt = FALSE
)
Arguments
train

(numpy.ndarray): A 2D numpy array of training data.

labels

(numpy.ndarray): A 1D numpy array of labels. Its length must be equal to the number of rows in “train“.

channel

(str): The SageMaker TrainingJob channel this RecordSet should be assigned to.

encrypt

(bool): Specifies whether the objects uploaded to S3 are encrypted on the server side using AES-256 (default: “False“).

Returns

RecordSet: A RecordSet referencing the encoded, uploading training and label data.


Method wait()

Wait for an Amazon SageMaker job to complete.

Usage
AmazonAlgorithmEstimatorBase$wait(logs = "All")
Arguments
logs

([str]): A list of strings specifying which logs to print. Acceptable strings are "All", "NULL", "Training", or "Rules". To maintain backwards compatibility, boolean values are also accepted and converted to strings.


Method clone()

The objects of this class are cloneable with this method.

Usage
AmazonAlgorithmEstimatorBase$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


DyfanJones/sagemaker-r-mlcore documentation built on May 3, 2022, 10:08 a.m.