Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I pass arguments to the entrypoint of a SageMaker estimator?

I'm using the SageMaker python sdk and was hoping to pass in some arguments to be used by my entrypoint, I'm not seeing how to do this.

from sagemaker.sklearn.estimator import SKLearn  # sagemaker python sdk

entrypoint = 'entrypoint_script.py'

sklearn = SKLearn(entry_point=entrypoint,  # <-- need to pass args to this
                  train_instance_type=instance_class,
                  role=role,
                  sagemaker_session=sm)
like image 583
Ryan Fisher Avatar asked May 03 '19 07:05

Ryan Fisher


People also ask

How do I initialize an estimatorbase instance in SageMaker?

Initialize an EstimatorBase instance. 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.

How do I train an estimator in SageMaker using Jupyter?

Instance of the calling Estimator Class with the attached training job. 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 the trained model to an Amazon SageMaker endpoint. And then return sagemaker.Predictor object.

How do I set the entry point for training on SageMaker?

You can assign entry_point=’src/train.py’. 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.

What are the different types of parameters in SageMaker model building pipelines?

Amazon SageMaker Model Building Pipelines supports the following parameter types: ParameterString – Representing a string parameter. ParameterInteger – Representing an integer parameter. ParameterFloat – Representing a float parameter. ParameterBoolean – Representing a Boolean Python type.


2 Answers

The answer is no as there is no parameter on the Estimator base class, or the fit method, that accepts arguments to pass to the entrypoint.

I resolved this by passing the parameter as part of the hyperparameter dictionary. This gets passed to the entrypoint as arguments.

like image 129
Ryan Fisher Avatar answered Sep 30 '22 02:09

Ryan Fisher


The entry_point argument here is for a script file that contains the codes you want to run training and prediction.

You can refer to the example here

And the entry_point script above example uses is here

like image 34
yay1 Avatar answered Sep 30 '22 03:09

yay1