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
    • 1.Neural Network Basics: From the Perceptron to Backpropagation
    • 2.CNN: Convolutional Neural Networks and Computer Vision
    • 3.RNNs and Sequence Models: From LSTM to Transformer
    • 4.Training Techniques and Transfer Learning
    • 5.Week 7 Synthesis: Deep Learning Summary
  • Week 8
  • Week 9
  • Week 10
  • Week 11
  • Week 12
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLS-C01/Week 7/Day 4

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

MLS-C01· AssociateWeek 7 · Day 4~32 min read

Day 4 - Training Techniques and Transfer Learning

📌 Key Takeaways

  • The problem type dictates the loss. Regression = MSE/MAE, classification = cross-entropy. Never use MSE for classification.
  • The default optimizer is Adam (adaptive, fast); a simple, robust alternative is SGD (+Momentum).
  • The learning rate is the top tuning target. Too large diverges, too small is slow → handle it with scheduling and warmup.
  • Five ways to prevent overfitting: dropout · weight decay (L2) · batch normalization · data augmentation · early stopping.
  • Transfer learning is decided by data volume × domain similarity. Little data and similar = freeze; lots of data or different = fine-tune with a low learning rate.

Training Creates Performance

Even after you choose the model structure, "how you train it" determines performance. Today covers the engine of deep learning training — loss functions, optimizers, and learning rate — then transfer learning and fine-tuning, which achieve a lot with little data, and the frameworks (TensorFlow/PyTorch) and SageMaker integration that appear on the exam. In this area MLS-C01 asks "what do you change when training fails, is slow, or overfits?"

Loss Function

It quantifies the difference between the model's predictions and the ground truth. You must choose it to match the problem type.

Problem typeLoss functionPaired output layerWhy
RegressionMSE (mean squared error), MAELinear (no activation)MSE penalizes large errors heavily; MAE is robust to outliers
Binary classificationBinary cross-entropy (BCE)Sigmoid, 1 nodeLog loss of the probability prediction
Multiclass classificationCategorical cross-entropySoftmax, K nodesCompares probability distributions
Imbalanced / detectionVariants such as Focal LossDepends on the taskLowers the contribution of easy majority samples
  • Using MSE for classification makes training slow and unstable, so cross-entropy is the standard.
  • The loss is training's "compass." If the loss curve does not fall, check the learning rate, structure, and data.

⚠️ Trap: Do not mix up the loss function (what is optimized) and the evaluation metric (the selection criterion). Just as high accuracy on imbalanced data does not make a good model, a low loss does not mean the business goal was met. Choose the metric separately, as one that reflects the cost structure, such as recall or PR-AUC.

Optimizer

The algorithm that actually updates the weights using the gradients obtained by backpropagation.

OptimizerCore ideaWhen to useCaution
SGDMoves a fixed fraction opposite the gradient, simple and robustBasic understanding, final fine-tuning of large modelsHeavy burden of learning-rate tuning
SGD + MomentumAccumulates past directions to reduce oscillation and accelerateWhen oscillating in a narrow, long valleyThe momentum coefficient is also a hyperparameter
RMSPropAdjusts the per-parameter learning rate by gradient magnitudeWhen gradient magnitudes differ greatly across parametersNo directional inertia on its own
AdamCombines Momentum + RMSProp, the deep learning defaultThe starting point for most casesOn very large models, SGD sometimes generalizes better
SGD:  w ← w - η * ∇L
Adam: adaptive per-parameter step size via 1st/2nd moment estimates

The practical default is Adam: fast convergence and little tuning. For the final fine-tuning of very large models, SGD sometimes shows better generalization.

Adam estimates the first moment (mean) and second moment (variance) of the gradient for each parameter and applies an adaptive learning rate. As a result it is less sensitive to the learning rate and converges quickly, making it the safe starting point for most deep learning projects. On the exam, if "deep learning training is too slow or learning-rate tuning is hard," Adam is the natural choice.

Learning Rate

The most important hyperparameter. It decides how far the weights move at once.

  • Too large: the loss diverges or oscillates and fails to converge (loss goes NaN or explodes).
  • Too small: convergence is excessively slow and training gets stuck in a local minimum.

Learning Rate Strategy Table

StrategyBehaviorWhenCaution
ConstantSame value from start to finishShort experiments, with AdamWanders around the minimum late in training
Step decayLowers by a fixed factor every set number of epochsLong training, finishing convergenceDecay timing and factor are extra tuning targets
CosineSmoothly lowers toward 0When the number of epochs is fixed in advanceCheck compatibility with early stopping
WarmupGradually raises over the first few stepsTransformers and others unstable early onA warmup period that is too long is wasteful
  • The basic sense of learning-rate scheduling: start large, then reduce gradually.
  • Warmup prevents large gradients in the first few steps from wrecking the weights.

Learning Curve Diagnosis Table

Training lossValidation lossDiagnosisRemedy
Explodes / NaN—Learning rate too large / exploding gradientsLower the learning rate, gradient clipping
Decreases very slowlyAlso slowlyLearning rate too smallRaise the learning rate, scheduling, Adam
Keeps decreasingRises from some pointOverfittingDropout, regularization, augmentation, early stopping
Stalls at a high valueStalls at a high valueUnderfittingEnlarge the model, train longer, add features
Decreases then oscillatesOscillatesLearning rate too large late in trainingApply a decay schedule

Learning curve diagnosis is the key. Loss explodes or oscillates → lower the learning rate. Training loss is low but validation loss rises → overfitting (dropout, regularization, augmentation, early stopping). Both training and validation loss are high → underfitting (enlarge the model, train more, add features). SageMaker Automatic Model Tuning (Bayesian optimization) can automatically search the learning rate, batch size, and number of layers.

Regularization and Preventing Overfitting

Deep learning overfits easily because it has so many parameters. The main remedies are broken down by technique, effect, when to use, and caution.

TechniqueEffectWhen to useCaution
DropoutRandomly turns off some neurons during training → prevents co-adaptationNetworks with large fully connected layersTurn it off at inference. Too high a rate causes underfitting
L2 weight decayPenalizes large weights → smoother decision boundaryAlmost always a default optionA large coefficient causes underfitting
L1 regularizationPushes weights to 0, making them sparseWhen a feature-selection effect is neededL2 is more common in deep learning
Batch normalization (BatchNorm)Normalizes layer inputs to stabilize and speed up trainingDeep CNNs and MLPsStatistics become unstable with very small batches
Data augmentationTransforms inputs to gain diversityFirst choice when data is scarceApply to the training set only. Do not break the meaning of the label
Early stoppingStops training when validation loss no longer decreasesAlmost alwaysNeeds a validation set and is sensitive to the patience setting

⚠️ Trap: Batch normalization and dropout have different purposes. Batch normalization is mainly for stabilizing and speeding up training (with a weak regularization effect as a side benefit), while dropout aims to suppress overfitting. Picking dropout for "training is unstable," or only batch normalization for "it is overfitting," points in the wrong direction.

What to Select the Model By — Metric Interpretation Table

Both early stopping and Automatic Model Tuning work only after you fix one metric to optimize. That choice is itself a business decision.

MetricWhat it tells youWhen to prioritizeTrap
AccuracyShare of all predictions that were rightOnly when classes are balancedWith 1% positives, "all negative" is also 99%
PrecisionOf those called positive, how many are truly positiveFalse-positive cost is highEasy to raise by predicting positive for only a few
RecallShare of actual positives caughtFalse-negative cost is highPredicting everything positive gives 1.0
F1Harmonic mean of precision and recallWhen the two costs are similarHides which side is the problem
ROC-AUCDiscrimination independent of thresholdComparing modelsOptimistic under extreme imbalance
PR-AUCDiscrimination for the minority classWhen the positive ratio is extremely lowValue changes if the class ratio changes
RMSE / MAESize of the regression errorTo penalize large errors / to be robust to outliersRMSE is sensitive to outliers

If you set the tuning objective metric to accuracy, the search converges in the wrong direction on imbalanced data. Decide the objective metric first so that it reflects the costly error type, and only then run tuning.

Transfer Learning

It transfers the knowledge of a model pretrained on large-scale data to a new task. It is powerful with little data and little time.

Pretrained model (ImageNet / large corpus)
   ├─ Backbone (feature extractor): reuse the weights
   └─ Head (output layer): replace and retrain for the new task
[Feature extraction — very little data]    [Fine-tuning — a moderate amount of data]
 
  ❄️ Conv block 1  (frozen)                  ❄️ Conv block 1  (stays frozen)
  ❄️ Conv block 2  (frozen)                  ❄️ Conv block 2  (stays frozen)
  ❄️ Conv block 3  (frozen)                  🔥 Conv block 3  (unfrozen with a low learning rate)
  🔥 New Dense head (trained)                🔥 New Dense head (trained)
 
  ❄️ = weights fixed   🔥 = updated
  "Gradual unfreezing" — train the head first, then progressively release the backbone — is stable.

Two approaches:

  • Feature extraction: freeze the backbone and train only the new head. For very little data.
  • Fine-tuning: retrain part or all of the backbone together at a low learning rate. For a moderate amount of data.

Data Volume × Domain Similarity Quadrants

Domain is similar to pretrainingDomain is different
Little dataFreeze the backbone + train only the head (feature extraction)Unfreeze only some upper layers with a low learning rate, combined with augmentation
Lots of dataFine-tune everything with a low learning rateWiden the fine-tuning scope or also consider training from scratch

Selection criteria summary:

  • Little data + similar domain → feature extraction (frozen).
  • Lots of data or different domain → fine-tuning (low learning rate).

When fine-tuning, use a much lower learning rate than when training from scratch so you do not ruin the pretrained weights. Also, "gradual unfreezing" — train the head first (backbone frozen), then progressively release the backbone — is stable. SageMaker JumpStart provides pretrained vision and NLP models and fine-tuning scripts, simplifying this process.

In transfer learning, "retrain all layers at once with a large learning rate" is a wrong answer. It erases the knowledge gained from pretraining within the first few steps.

Frameworks and SageMaker Integration

FrameworkCharacteristic
TensorFlow / KerasRich industrial deployment and serving ecosystem, high-level API with Keras
PyTorchDynamic graphs make it friendly for research and debugging, currently the most widely used
MXNetThe basis of some SageMaker built-ins (in the past)

Use in SageMaker:

  • Script Mode: run your own TF/PyTorch script in a SageMaker training container.
  • Prebuilt containers / Deep Learning Containers (DLC): managed images for each TF and PyTorch version.
  • Distributed training: data-parallel and model-parallel libraries, multi-GPU and multi-instance.
  • SageMaker JumpStart: deploy and fine-tune pretrained models and solutions by click or script.
  • Consider ml.p and ml.g instances for GPU training, and ml.inf (Inferentia) and similar for optimizing inference cost.

Situation → AWS Choice Mapping Table

SituationChoiceWhy
Run your own training script as a managed jobScript ModeRuns your code as-is in the training container
Do not want to build the framework environment yourselfDeep Learning ContainersManaged images per version
Automatically search learning rate, batch size, dropoutAutomatic Model TuningEfficient search via Bayesian optimization
The model does not fit on one GPUModel-parallel distributed trainingSplits the model across several devices
Data is large and one instance is too slowData-parallel distributed trainingSplits the batch across several devices
Start quickly from a pretrained modelJumpStartProvides the model + fine-tuning scripts
Want to lower inference costConsider the ml.inf (Inferentia) familyInference-specialized accelerators

Symptom → Cause → Remedy

SymptomCauseFirst remedy
Loss explodes to NaNLearning rate too largeLower the learning rate
Convergence is too slowLearning rate too small, unsuitable optimizerRaise the learning rate, scheduling, Adam
Training loss ↓, validation loss ↑OverfittingDropout, L2, augmentation, early stopping
Both losses highUnderfittingEnlarge the model, train longer, add features
Only 1,000 training imagesInsufficient dataTransfer learning (frozen) + augmentation
Performance actually drops after fine-tuningLearning rate too large destroyed prior knowledgeCut the learning rate drastically, gradual unfreezing
Training fails with OOMBatch or model too largeReduce the batch, model parallelism
Too many hyperparameter combinationsLimits of manual searchAutomatic Model Tuning

The next post compresses all of Week 7 into one decision map and organizes confusable concept pairs from a comparison perspective.

📖 Glossary

  • Loss function: a single number summarizing the difference between predictions and ground truth. What training tries to minimize.
  • Optimizer: the algorithm that actually updates the weights using the gradients obtained by backpropagation.
  • Adam: an optimizer that combines Momentum and RMSProp to use adaptive per-parameter steps. The deep learning default.
  • Learning rate: the value that sets how far the weights move at once. The first thing to tune.
  • Learning rate warmup: a technique that gradually raises the learning rate over the first few steps to prevent early instability.
  • Dropout: an overfitting-suppression technique that randomly turns off some neurons during training to prevent co-adaptation.
  • Weight decay (L2): regularization that penalizes large weights to make the model smoother.
  • Batch normalization: a technique that normalizes the distribution of layer inputs to stabilize and speed up training.
  • Early stopping: a technique that stops training when validation loss no longer decreases, preventing overfitting.
  • Transfer learning / fine-tuning: taking and reusing pretrained weights / retraining those weights together at a low learning rate.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

As soon as training starts, the loss explodes to NaN. What remedy should you try first?

Question 2

You have only 1,000 training images, but the domain is similar to ImageNet. What is the MOST efficient strategy?

Question 3

What is the standard loss function for a multiclass classification neural network?

Question 4

Which optimizer is recommended as the default in most deep learning projects because it requires little learning rate tuning and converges quickly?

Question 5

The training loss keeps decreasing, but the validation loss starts rising again from some point. What is the MOST appropriate response?

PreviousRNNs and Sequence Models: From LSTM to TransformerWeek 7 · Day 3Next Week 7 Synthesis: Deep Learning SummaryWeek 7 · Day 5

Official references

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

On this page

  • Key Takeaways
  • Training Creates Performance
  • Loss Function
  • Optimizer
  • Learning Rate
  • Learning Rate Strategy Table
  • Learning Curve Diagnosis Table
  • Regularization and Preventing Overfitting
  • What to Select the Model By — Metric Interpretation Table
  • Transfer Learning
  • Data Volume × Domain Similarity Quadrants
  • Frameworks and SageMaker Integration
  • Situation → AWS Choice Mapping Table
  • Symptom → Cause → Remedy
  • Glossary
  • Practice Questions