Space4VV
Space4VV

Reputation: 135

How to pass the experiment configuration to a SagemakerTrainingOperator while training?

Idea:

I am using the training_config to create the dict to pass the training configuration to the Tensorflow estimator, but there is no parameter to pass the experiment configuration

tf_estimator = TensorFlow(entry_point='train_model.py',
                                      source_dir= source
                                      role=sagemaker.get_execution_role(),
                                      instance_count=1,
                                      framework_version='2.3.0',
                                      instance_type=instance_type,
                                      py_version='py37',
                                      script_mode=True,
                                      enable_sagemaker_metrics = True,
                                      metric_definitions=metric_definitions,
                                      output_path=output

model_training_config = training_config(
                    estimator=tf_estimator,
                    inputs=input
                    job_name=training_jobname,
                )
    



training_task = SageMakerTrainingOperator(
                    task_id=test_id,
                    config=model_training_config,
                    aws_conn_id="airflow-sagemaker",  
                    print_log=True,
                    wait_for_completion=True,
                    check_interval=60  
                )

Upvotes: 0

Views: 488

Answers (2)

Space4VV
Space4VV

Reputation: 135

The only way that i found right now is to use the CreateTrainigJob API (https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-RoleArn). The following steps are needed:

  • I am not sure if this will work with Bring your own script method for E.g with a Tensorflow estimator
  • it works with a build your own container approach
  • Using the CreateTrainigJob API i created the configs which in turn includes all the needed configs like - training, experiment, algporthm etc and passed that to SagemakerTrainingOperator

Upvotes: 0

Anoop
Anoop

Reputation: 130

You can use the experiment_config in estimator.fit. More detailed example can be found here

Upvotes: 1

Related Questions