Courseiva
ML Model Development →mediumMultiple Choice

MLA-C01 ML Model Development Practice Question

A data scientist is using SageMaker to train a deep learning model with the PyTorch estimator. They want to log custom scalar metrics such as validation accuracy and loss during training so they can monitor the job in SageMaker. Which approach should they use to emit these metrics from the training script?

⚠ Common exam trap

The trap here is assuming there is a dedicated metrics API inside the container, when SageMaker actually parses stdout logs using regex patterns.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Print the metrics to stdout in a consistent format and define regex patterns in the estimator's metric_definitions parameter.

For SageMaker training jobs, custom metrics are captured by parsing the job's logs. The PyTorch estimator supports metric_definitions, a list of name and regex pairs. Printing metrics to stdout in a consistent format lets SageMaker extract them for monitoring and tuning. Direct API calls or file writes are not the supported mechanism for estimator metric capture.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use the sagemaker_metrics API to write metrics to a local file and pass its path to the estimator's metric_definitions.

    Why it's wrong here

    There is no sagemaker_metrics API for writing metrics to a file for the estimator. SageMaker captures metrics by parsing stdout/stderr logs using regex patterns defined in metric_definitions. Writing to a local file would not be automatically picked up unless the script also prints the values. This approach misidentifies the mechanism and would not reliably surface custom metrics in the training job.

  • ✓

    Print the metrics to stdout in a consistent format and define regex patterns in the estimator's metric_definitions parameter.

    Why this is correct

    SageMaker extracts training metrics by parsing the job's logs. When using the PyTorch estimator, the training script should print metric values to stdout in a predictable format, and the estimator's metric_definitions parameter provides regex patterns to capture them. This is the standard, supported method for custom scalar metrics and integrates with SageMaker monitoring and automatic model tuning.

  • ✗

    Call the SageMaker Metrics API directly from the training container to publish each metric.

    Why it's wrong here

    Calling the SageMaker Metrics API from within the training container is not the standard pattern for custom metrics in a PyTorch estimator job. It would require additional IAM permissions and SDK setup inside the container, and it is not how metric_definitions works. The intended approach is to print metrics to logs and let SageMaker parse them, avoiding extra API calls and complexity.

  • ✗

    Store metrics in Amazon CloudWatch Logs using the PutMetricData API and then reference them in the estimator.

    Why it's wrong here

    While CloudWatch Logs captures stdout, the PutMetricData API publishes custom CloudWatch metrics, not SageMaker training metrics parsed by the estimator. The estimator's metric_definitions expects regex patterns over logs. Using PutMetricData would not populate the training job's metric list or support automatic model tuning objectives. It also adds unnecessary API calls and permissions outside the standard workflow.

About these practice questions

This MLA-C01 question is part of Courseiva's 665-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint

This MLA-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the MLA-C01 exam.