1 Answer
- Newest
- Most votes
- Most comments
0
When you create a training step, you need to pass in an Estimator object as an argument to the training step. Notice the xgb_estimator object in the code below. You can pass in a source_dir argument to the estimator and add additional code dependencies at that location.
Create the Estimator
from sagemaker.xgboost.estimator import XGBoost
xgb_estimator = XGBoost(
entry_point="abalone.py",
source_dir="code",
hyperparameters=hyperparameters,
role=role,
instance_count=1,
instance_type="ml.m5.2xlarge",
framework_version="1.0-1",
)
Provide the Estimator as an argument to the Training step
from sagemaker.workflow.pipeline_context import PipelineSession
from sagemaker.inputs import TrainingInput
from sagemaker.workflow.steps import TrainingStep
from sagemaker.xgboost.estimator import XGBoost
pipeline_session = PipelineSession()
xgb_estimator = XGBoost(..., sagemaker_session=pipeline_session)
step_args = xgb_estimator.fit(
inputs={
"train": TrainingInput(
s3_data=step_process.properties.ProcessingOutputConfig.Outputs[
"train"
].S3Output.S3Uri,
content_type="text/csv"
),
"validation": TrainingInput(
s3_data=step_process.properties.ProcessingOutputConfig.Outputs[
"validation"
].S3Output.S3Uri,
content_type="text/csv"
)
}
)
step_train = TrainingStep(
name="TrainAbaloneModel",
step_args=step_args,
)
answered a year ago
Relevant content
- asked 2 years ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago