CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
  • Week 1
    • 1.The ML Lifecycle (from a Specialty Perspective)
    • 2.Data Storage for ML: S3, EFS, FSx for Lustre, and Data Formats
    • 3.Data Ingestion: Kinesis, Glue, Batch vs. Streaming
    • 4.Data Labeling: SageMaker Ground Truth, Active Learning, Label Quality
    • 5.Week 1 Comprehensive Review: ML Overview & Data Engineering 1
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
    • 1.SageMaker Training Jobs: Estimator, Input Modes, Distributed Training, Spot
    • 2.Hyperparameter Tuning (AMT): Bayesian, Random, Hyperband
    • 3.Overfitting/Underfitting: Diagnosis and Regularization/Data Augmentation
    • 4.Learning Optimization: Batch Size, Learning Rate, Gradient Issues, Debugger/Profiler
    • 5.Week 8 Comprehensive Review: Training, Tuning, Generalization
  • Week 9
  • Week 10
  • Week 11
  • Week 12
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLS-C01/Week 8/Day 5

Based on the MLS-C01 exam guide·Report an error

MLS-C01· AssociateWeek 8 · Day 5~29 min read

Day 5 - Week 8 Comprehensive Review: Training, Tuning, Generalization

📌 Key Takeaways

  • Week 8 is the second half of Domain 3 (Modeling) — four flows: train (Day 1), tune (Day 2), generalize (Day 3), and make it converge well (Day 4).
  • Every problem splits along two axes: the optimization axis (does it reduce training loss well: learning rate, batch, gradients) and the generalization axis (does it fit new data: regularization, data, validation). First work out which axis the symptom belongs to.
  • Data size, model size, cost → training infrastructure (input mode, distribution, Spot); efficiency, cost → tuning strategy (Bayesian/Hyperband/early stopping).
  • Size of the gap → overfitting/underfitting remedy; symptom → optimization cause and tool (quality = Debugger, resources = Profiler).
  • Easy-to-confuse traps: responding to overfitting with more epochs or a bigger model, missing checkpoints with Spot (max_wait >= max_run), and using Accuracy as the objective metric on imbalanced data.

The Week at a Glance

[Day1] Training execution foundation
  Estimator → input mode (File/Pipe/FastFile) → distribution (data/model parallel) → Spot + checkpoints
 
[Day2] Hyperparameter tuning (AMT)
  search space · objective metric → strategy (Bayesian/Random/Grid/Hyperband) → early stopping → warm start
 
[Day3] Generalization
  diagnose overfitting/underfitting (bias-variance) → regularization (L1/L2/dropout/early stopping) → data augmentation → leakage prevention
 
[Day4] Training optimization
  batch size · learning rate schedule → vanishing/exploding gradients → Debugger (quality) / Profiler (resources)

💡 Related Theory: The core tension in the second half of modeling is two axes. (1) Optimization — does it reduce the loss on training data well (learning rate, batch, gradients). (2) Generalization — does it fit new data well (regularization, data, validation). These are different. If optimization succeeds (low training loss) but generalization fails (high validation loss), that is overfitting. Exam questions are almost always designed to first ask "is this symptom an optimization problem or a generalization problem?"

Integrated Decision Tree

A training-related problem is given
├─ ① Is this a stage where you can't even run training yet? (infrastructure)
│    ├─ Data is larger than the disk / want to cut startup delay → Pipe / FastFile
│    ├─ Download everything and access randomly                   → File
│    ├─ Training is slow + the model fits on a GPU                → data parallel
│    ├─ The model exceeds single-GPU memory                       → model parallel
│    └─ Cost reduction (delay tolerated)  → Managed Spot + checkpoint_s3_uri
│                               (max_wait >= max_run required)
├─ ② Training runs but convergence looks wrong? (optimization — Day 4)
│    ├─ NaN · divergence · oscillation → lower learning rate + gradient clipping
│    ├─ Early layers stalled · plateau → vanishing → ReLU · BN · residual · initialization
│    ├─ OOM                            → lower batch / gradient accumulation / mixed precision
│    └─ GPU underused · slow · expensive → diagnose the bottleneck with Profiler
├─ ③ It converges but performance is bad? (generalization — Day 3)
│    ├─ Train high, validation low, large gap → overfitting → stronger regularization · more data · augmentation · dropout · early stopping
│    ├─ Both train and validation low         → underfitting → more complexity · features · longer training
│    └─ Validation score unrealistic          → leakage → check fit scope · target-derived features
└─ ④ Performance is fine but you need to squeeze out more? (tuning — Day 2)
     ├─ Efficient search with few evaluations → Bayesian
     ├─ Deep learning epoch iteration + pruning → Hyperband
     ├─ Reduce tuning cost → early stopping (Auto) or Hyperband
     └─ Reuse a previous tuning job → warm start

Day 1 Summary — Input Modes, Distribution, Spot

CueChoice
Data exceeds the disk, reduce startup delayPipe / FastFile
Download everything and access randomlyFile
Speed up training, model fits on a GPUData parallel
Model exceeds single-GPU memoryModel parallel
Cost reduction (some delay tolerated)Managed Spot + checkpoint_s3_uri

Only what you write to /opt/ml/model is uploaded to S3, and Spot requires max_wait >= max_run — remember these as trap points.

Day 2 Summary — Tuning Strategies

CueStrategy
Efficient search with few evaluationsBayesian
Deep learning epoch iteration, fast pruningHyperband
Simple, fully parallel baselineRandom
Exhaustive search over a few categorical combinationsGrid
Reduce tuning costAutomatic early stopping / Hyperband
Continue from a previous tuning jobWarm start

The objective metric for imbalanced data is F1/AUC, not Accuracy. With Bayesian, raising parallelism too high lowers how much it can use earlier results.

Objective Metrics — What Do You Optimize

Tuning optimizes only in the direction the objective metric points. If the metric choice is wrong, you get a well-tuned but meaningless model.

SituationObjective metricDirectionWhy
Balanced classificationAccuracy, AUCMaximizeAccuracy moves honestly
Imbalanced classification (fraud detection, etc.)F1, AUC, RecallMaximizeWith 1% positives, "all negative" gives 99% accuracy — Accuracy is a trap
Missing a case is fatal (disease, fraud)RecallMaximizeThe cost of a false negative is greater
False alarms are costlyPrecisionMaximizeFalse positives create real operational cost
RegressionRMSE, MAEMinimizeDirection that reduces error
Custom scriptmetric_definitions regex required—The value must be parsed from the logs for AMT to compare

Day 3 Summary — Generalization Diagnosis and Remedies

SymptomDiagnosisRemedy
Train high, validation low (large gap)Overfitting (high variance)Stronger regularization, more data, dropout, early stopping, augmentation
Both train and validation lowUnderfitting (high bias)More complexity, more features, longer training
Need feature selection / sparse model—L1
Want to shrink all weights—L2

Scalers and encoders are fit on the training set only — this is the basis of leakage prevention.

Day 4 Summary — Optimization and Tools

SymptomRoot causeResponse
NaN / divergence / oscillationLearning rate too high, exploding gradientsLower learning rate, gradient clipping
Early layers not learning, loss plateauVanishing gradientsReLU, batch normalization, residual connections, initialization
OOMExcessive batch sizeLower batch, gradient accumulation, mixed precision
Automatic detection of quality anomalies—Debugger
Resource bottleneck, GPU underuse—Profiler

Services and Features Master Table

FeatureWhat it doesWhen to pick itConfusion warning
Training Job (Estimator)Managed one-off training runWhen running training as a containerThe instance exists only for the duration of the job
Input mode File/Pipe/FastFileHow data is delivered from S3 to the containerDepending on data size and startup-delay requirementsPipe = streaming, FastFile = lazy loading + random access
Data parallel / model parallelDistribute training across multiple devicesSpeed problem vs model size problemTell whether "GPU memory exceeded" is caused by the model or the batch
Managed Spot TrainingCheap, interruptible instancesCost reduction is the goal, delay is toleratedWithout checkpoints, the savings are meaningless
AMT (tuning job)Automatic hyperparameter searchWhen you need to find the optimal combinationCan't fix convergence problems in training itself
DebuggerDetects quality anomalies from tensors during trainingVanishing, exploding, overfitting, stalled lossNot for resource analysis
ProfilerAnalyzes CPU/GPU and I/O resource bottlenecksGPU underuse, slowness, cost inefficiencyNot for detecting quality anomalies
Model MonitorWatches drift on deployed endpointsThe operations stage, not trainingPicking it for anomaly detection during training is wrong

Settings Master Table — Where the Traps Hide

SettingWhereWhat happens if you miss it
output_path / /opt/ml/modelEstimatorOnly what is written to this path is uploaded to S3 automatically
input_mode (File/Pipe/FastFile)TrainingInputWith File, training doesn't start until the download finishes
instance_count + distributionEstimatorIf you only add instances without choosing a distribution strategy, it won't work as intended
use_spot_instances + max_waitEstimatorUnless max_wait >= max_run, the Spot configuration isn't valid
checkpoint_s3_uriEstimatorWithout it, a Spot interruption means retraining from scratch
strategy / early_stopping_typeHyperparameterTunerHyperband has early stopping built in and ignores early_stopping_type
max_jobs / max_parallel_jobsHyperparameterTunerWith Bayesian, raising parallelism too high lowers efficiency
objective_metric_nameHyperparameterTunerPutting Accuracy on imbalanced data makes the tuning itself futile
l1 / wdLinear Learnerwd is L2 (weight decay) — only the name differs
gradient_clipping / lr_schedulerTraining hyperparametersFirst-line means of handling explosion and divergence

Thinking Through Integrated Cases

Case A: A text classification model has 96% training accuracy and 75% validation accuracy. Data is scarce and collecting more is hard. You also want to cut tuning cost.

Solution:

  1. Large gap → overfitting (Day 3) → stronger regularization, data augmentation (back-translation, etc.), dropout.
  2. Little data → stabilize evaluation with k-fold cross-validation.
  3. Reduce tuning cost → Hyperband or early stopping (Day 2).

Case B: You are training a large model on 8TB of data and it is too slow and too expensive. It also exceeds single-GPU memory.

Solution:

  1. Data exceeds disk → Pipe/FastFile (Day 1).
  2. Exceeds a single GPU → model parallel (Day 1).
  3. Cost reduction → Spot + checkpoints (Day 1).
  4. If GPU underuse is suspected → identify the bottleneck with Profiler (Day 4).

Commonly Missed Traps

TrapWhy it's wrongCorrect judgment
Responding to overfitting with "more epochs / bigger model"It increases variance and makes things worseRegularization, data, augmentation, early stopping
Reflex "GPU memory exceeded = model parallel"The cause may be the batchThe model itself doesn't fit → model parallel / because of the batch → accumulation, mixed precision, lower batch
Confusing Debugger and ProfilerThey look at different thingsQuality = Debugger, resources = Profiler, post-deployment drift = Model Monitor
Using Spot without checkpointsAn interruption means retraining from scratch → savings vanishSet checkpoint_s3_uri, max_wait >= max_run
Accuracy as the objective metric on imbalanced dataPredicting only the majority class still scores highF1 / AUC / Recall
Merging the validation set into training to raise performanceMeasuring generalization becomes impossibleValidation is for selection, test is scored once at the end
Fitting a scaler on the whole datasetTest information leaks into trainingfit on the training set only, transform for the rest
Setting maximum parallelism for BayesianIt decides the next trial without seeing earlier resultsModerate parallelism; fully parallel suits Random

Question Cue → Answer Mapping

Question cueAnswer to pickWhich Day
"Training loss is very low but validation loss is much higher"Optimization succeeded, generalization failed = overfittingDay 3
"Both training and validation are low and the gap is small"Underfitting → more complexity · features · trainingDay 3
"The data is larger than the instance disk"Pipe / FastFile input modeDay 1
"The model exceeds single-GPU memory"Model parallelDay 1
"Cut cost substantially but delay is tolerated"Managed Spot + checkpointsDay 1
"Quickly discard hopeless candidates to cut tuning cost"HyperbandDay 2
"Search efficiently with few training runs"BayesianDay 2
"Continue exploring from last tuning job's results"Warm startDay 2
"Objective metric for data with 1% positives, like fraud detection"F1 / AUC (Accuracy is a trap)Day 2
"Automatically zero out features to get a sparse model"L1Day 3
"Labeling cost is high so you can't grow the data"Data augmentationDay 3
"Loss suddenly diverges to NaN"Lower learning rate + gradient clippingDay 4
"GPU utilization 30%, suspect data-loading bottleneck"ProfilerDay 4
"Automatically detect and alert on vanishing, overfitting, non-decreasing loss"DebuggerDay 4
"Monitor input distribution changes after deployment"Model Monitor (next week's scope)Week 9

Next week moves to Domain 4 and covers how to deploy, operate, and monitor models.

📖 Glossary

  • Optimization / generalization: The problem of reducing loss well on training data (learning rate, batch, gradients) / the property that performance holds on new data too (regularization, data, validation). Separating these two axes is the starting point for solving Week 8 questions.
  • Input mode: How training data in S3 is delivered to the container. File (full download), Pipe (streaming), FastFile (lazy loading).
  • Data parallel / model parallel: Replicating the same model and splitting the data / splitting the model itself across multiple devices.
  • Managed Spot Training / checkpoint: An option that reduces cost by training on cheap instances that can be interrupted / a state snapshot that lets training resume from that point after an interruption. The two are a set.
  • AMT (Automatic Model Tuning): A SageMaker feature that automatically searches hyperparameter combinations across multiple training jobs to find the optimum.
  • Hyperband / warm start: A multi-fidelity strategy that allocates resources unevenly and cuts hopeless candidates early / a setting that starts from earlier tuning results and continues the search.
  • Objective metric: The validation metric that tuning maximizes or minimizes. What you choose is what you optimize, and picking Accuracy on imbalanced data makes tuning futile.
  • Bias-variance tradeoff: The relationship where making the model simpler increases bias and making it more complex increases variance. The goal is the point where their sum is minimal.
  • Debugger / Profiler: A tool that catches quality anomalies during training (vanishing, exploding, overfitting) / a tool that analyzes CPU, GPU, I/O resources and bottlenecks. The pair most often mixed up on the exam.
  • Drift: The phenomenon where the real input or prediction distribution after deployment differs from that at training time. It is the subject of Model Monitor.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

A model's training loss is very low, but its validation loss is much higher. Which statement BEST characterizes this situation?

Question 2

The 8 TB of training data is larger than the instance disk, the model exceeds a single GPU's memory, and you also want to reduce cost. Which combination is MOST appropriate?

Question 3

In deep learning tuning, you want to converge quickly without wasting resources on unpromising candidates while reducing tuning cost. Which AMT strategy is MOST suitable?

Question 4

During training, the loss suddenly diverged to NaN. Which of the following should be checked and applied first?

Question 5

Training converges normally, but GPU utilization is low at 30% and you suspect a data loading bottleneck. You want to analyze resource utilization to improve cost and speed. Which tool is MOST suitable?

PreviousLearning Optimization: Batch Size, Learning Rate, Gradient Issues, Debugger/ProfilerWeek 8 · Day 4Next Classification Evaluation Metrics: Accuracy, Precision, Recall, F1, and the Confusion MatrixWeek 9 · Day 1

Official references

  • MLS-C01 official exam page(opens in a new tab)
  • Amazon S3 documentation(opens in a new tab)
  • Amazon SageMaker AI documentation(opens in a new tab)

On this page

  • Key Takeaways
  • The Week at a Glance
  • Integrated Decision Tree
  • Day 1 Summary — Input Modes, Distribution, Spot
  • Day 2 Summary — Tuning Strategies
  • Objective Metrics — What Do You Optimize
  • Day 3 Summary — Generalization Diagnosis and Remedies
  • Day 4 Summary — Optimization and Tools
  • Services and Features Master Table
  • Settings Master Table — Where the Traps Hide
  • Thinking Through Integrated Cases
  • Commonly Missed Traps
  • Question Cue → Answer Mapping
  • Glossary
  • Practice Questions