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 1

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

MLS-C01· AssociateWeek 7 · Day 1~31 min read

Day 1 - Neural Network Basics: From the Perceptron to Backpropagation

📌 Key Takeaways

  • Perceptron = weighted sum + bias + activation. Without a nonlinear activation, no matter how many layers you stack, the network is equivalent to a single linear model.
  • The default hidden-layer activation is ReLU; the output depends on the task: binary = Sigmoid / multiclass = Softmax / regression = linear.
  • The training loop has four steps: forward pass (prediction) → loss (error) → backpropagation (gradients) → gradient descent (update).
  • The problem type decides the loss. Regression = MSE/MAE, binary = BCE, multiclass = categorical cross-entropy. MSE for classification is wrong.
  • Epochs, batches, and iterations come up as calculation problems. Iterations per epoch = number of samples ÷ batch size.

When to Reach for Deep Learning

Week 7 covers deep learning, the second pillar of Domain 3 (Modeling). Unstructured data that trees and linear models cannot handle (images, text, audio) and complex nonlinear relationships are deep learning's stage.

Data shapeFirst candidateWhen to use deep learningSignals not to use it
Structured (tabular) dataTree ensembles such as XGBoostWhen feature interactions are very complex and data is abundant"a few thousand rows", "training time limit"
Images, videoCNNEffectively the default choiceVery little data → transfer learning is assumed
Sequences (time series, text)RNN/LSTM/GRU, TransformerWhen order and context create meaningTabular data where order is meaningless
Large-scale language and generationTransformer familyAssumes using a pretrained modelOptions that say to train from scratch
  • MLS-C01 does not ask about deep learning at the level of framework coding. It presents scenarios that assume a conceptual understanding of perceptrons, activations, loss, backpropagation, and hyperparameters.
  • Today we get the big picture of how a neural network turns input into predictions and how it learns.

⚠️ Trap: If you memorize "deep learning = always better," you will get a small-tabular-data question wrong. If the data is small and tabular, a tree ensemble is the answer candidate.

The Perceptron: The Smallest Unit of a Neural Network

A perceptron is a single neuron that multiplies inputs by weights, sums them, adds a bias, and passes the result through an activation function.

z = w1*x1 + w2*x2 + ... + wn*xn + b
a = f(z)        # f = activation function
ElementSymbolRoleIs it learned?
WeightwImportance of each inputYes (the core parameter)
BiasbShifts the decision boundary in parallelYes
ActivationfInjects nonlinearityNo (chosen by the designer)
  • A single perceptron can only do linear separation (it cannot solve XOR).
  • This limitation is the motivation for the multilayer perceptron (MLP), which stacks hidden layers.

Without an activation function, no matter how many layers you stack, it is a composition of linear transformations and ends up equivalent to a single linear model. Only with a nonlinear activation can a neural network represent complex, curved decision boundaries. This is the fundamental reason "deep" learning has expressive power.

Hidden Layers and the Multilayer Perceptron (MLP)

If you place one or more hidden layers between the input layer and the output layer, a neural network can approximate nonlinear functions.

Input layer  →  Hidden layer 1  →  Hidden layer 2  →  Output layer
(features)      (low-level         (high-level         (prediction)
                 patterns)          patterns)
  • The width of a layer (number of neurons) and the depth (number of layers) determine the model capacity.
  • The deeper and wider it is, the greater the expressive power, but the greater the risks of overfitting, compute cost, and vanishing gradients.
  • Universal approximation theorem: a single-hidden-layer MLP with enough neurons can approximate any continuous function. However, stacking "deeper" often achieves the same expressive power with fewer parameters.
When you increase model capacityWhat you gainWhat you lose
Deeper layersHierarchical abstraction, parameter efficiencyVanishing gradients, unstable training
Wider layersMore diverse patterns in the same layerParameter explosion, overfitting, memory

Activation Functions

The key element that injects nonlinearity between layers. The exam asks "what to use where."

FunctionOutput rangeMain useVanishing gradientCaveat
Sigmoid(0, 1)Binary classification outputSevere at both endsOutput is not zero-centered
Tanh(-1, 1)Hidden layers (legacy)Present at both endsZero-centered, so training is more stable than Sigmoid
ReLU[0, ∞)Default for hidden layersNone in the positive region"Dead ReLU" on negative inputs
Leaky ReLU(-∞, ∞)When ReLU diesNoneKeeps a small negative slope to keep the neuron alive
Softmax(0,1), sums to 1Multiclass classification output—Produces a probability distribution over classes
Linear (none)(-∞, ∞)Regression output—If used in a hidden layer, nonlinearity disappears
# Conceptual definitions
relu(z)    = max(0, z)
sigmoid(z) = 1 / (1 + exp(-z))
softmax(z_i) = exp(z_i) / sum(exp(z_j) for all j)

Selection guide:

  • Hidden layers: The default is ReLU (or variants such as Leaky ReLU and GELU). It is resistant to vanishing gradients and fast.
  • Binary classification output: Sigmoid with 1 node.
  • Multiclass classification output: Softmax (as many nodes as classes).
  • Regression output: Linear with no activation (or a function that fits the output range).

When the input is large or small, the derivatives of Sigmoid/Tanh approach 0, so the gradient keeps shrinking during backpropagation, causing the vanishing gradient problem. ReLU keeps the gradient constant at 1 in the positive region and greatly eases this problem, but because it always outputs 0 for negative inputs, some neurons can become permanently inactive ("dead ReLU"), and Leaky ReLU appeared to prevent this.

⚠️ Trap: In options asking about the output-layer activation, ReLU and Tanh get mixed in. These two are for hidden layers. If you need probabilities, use Sigmoid/Softmax; for continuous values, use linear.

Forward Pass and Loss

Training happens through flows in two directions. First, the forward pass produces a prediction.

Input → repeat (weighted sum + activation) at each layer → final prediction ŷ

The difference between the prediction ŷ and the actual answer y is quantified by the loss function (loss).

Loss Function Selection Table

Problem typeOutput layerLoss functionWhy
RegressionLinear (no activation)MSE (mean squared error)Penalizes large errors heavily
Regression (many outliers)LinearMAE (absolute error)Less affected by outliers
Binary classificationSigmoid, 1 nodeBinary cross-entropy (BCE)Log loss of probability predictions
Multiclass (mutually exclusive)Softmax, K nodesCategorical cross-entropyCompares probability distributions
Multilabel (can co-occur)Sigmoid, K nodesSum of per-label BCEClasses are not mutually exclusive
  • Using MSE for classification makes training slow and unstable, so cross-entropy is the standard.
  • The smaller the loss, the better the model. The goal of training is to find "the weights that minimize the loss."

The loss is the optimization target, while the evaluation metric is the business decision criterion. If a question asks "which metric should be used to choose a model" and you pick the training loss, it is wrong.

Loss and Evaluation Metrics Are Different — Metric Interpretation Table

MetricCalculationWhat a high value meansWhen to prioritizeTrap
Accuracy(TP+TN)/totalOften right overallOnly when classes are balancedIf imbalanced, 99%+ even with "all negative"
PrecisionTP/(TP+FP)Few false positivesFalse positives are costlyEasily raised by predicting positive for only a few
RecallTP/(TP+FN)Few missesMisses are costly (fraud, disease)1.0 if you predict everything positive
F1Harmonic mean of precision and recallA good balance of bothWhen the two costs are similarHides which side is the problem
ROC-AUCArea under the TPR-FPR curveDiscrimination independent of thresholdThreshold undecided, comparing modelsOptimistic under extreme imbalance
PR-AUCArea under the precision-recall curveDiscrimination for the minority classWhen the positive rate is extremely lowThe value also changes when the class ratio changes
RMSESquare root of the mean squared errorFew large errorsRegression, when large errors should be penalized heavilySensitive to outliers
MAEMean of absolute errorsSmall average errorRegression, when robustness to outliers is neededTreats large errors leniently

Accuracy is meaningless on imbalanced data. If positives are 1%, just predicting "all negative" gives 99%. If the question says "positive cases are very rare," discard the accuracy option first and look at recall and PR-AUC.

Backpropagation

To reduce the loss, you need to know how much each weight contributes to it. Backpropagation computes the gradient of the loss by propagating it from the output layer toward the input layer using the chain rule.

1. Forward pass: compute the prediction ŷ
2. Compute the loss: L(ŷ, y)
3. Backpropagation: compute ∂L/∂w from output to input using the chain rule
4. Update the weights: w ← w - η * ∂L/∂w   (η = learning rate)
5. Repeat 1~4 per batch/epoch

Forward pass from input to loss, and backpropagation passing gradients backward through the chain rule

  • The gradient tells you "if I increase this weight, in which direction and by how much does the loss change."
  • With gradient descent, the weights are moved a little at a time in the direction opposite to the gradient.
  • This process is repeated tens of thousands to hundreds of thousands of times in batches of data to lower the loss.

Backpropagation is paired with the optimizer (Day 4). Backpropagation computes "in which direction," and the optimizer decides "how much and how" to move.

As layers get deeper, the product of derivatives in the chain rule gets longer. If each term is less than 1, the product converges to 0, causing a vanishing gradient; if greater than 1, it diverges, causing an exploding gradient. That is why deep networks combine activation choice (ReLU), normalization (batch normalization), and structural shortcuts (residual connections).

Epoch, Batch, Iteration

TermMeaning
EpochOne full pass through all the training data
BatchA group of samples used for a single weight update
Batch sizeNumber of samples in one batch (memory vs stability trade-off)
IterationProcessing one batch = one weight update
  • Example: with 1000 samples and a batch size of 100, one epoch = 10 iterations.
  • Formulas: iterations per epoch = number of samples ÷ batch size, total updates = iterations per epoch × number of epochs.

Batch Size Trade-offs

Batch sizeGradient estimateMemory/GPUGeneralization tendencyTypical situation
LargeStable (less noise)Uses a lot, high GPU utilizationMay get slightly worseLarge-scale GPUs, goal is fast throughput
SmallNoisyUses littleSometimes helps escape local minimaOut of memory (OOM), small data

A large batch size gives a stable gradient estimate and high GPU utilization, but uses a lot of memory and may slightly worsen generalization. A small one mixes in noise, which sometimes helps escape local minima. On the exam, if "training fails due to out of memory (OOM)," reducing the batch size is the first-line remedy.

Symptom → Cause → Remedy

SymptomCauseFirst-line remedy
Loss is NaN/explodesLearning rate too high, exploding gradientsLower the learning rate
Convergence is very slowLearning rate too lowRaise the learning rate or use scheduling, adaptive optimizers
Making the network deeper made it worseVanishing gradientsReLU family, batch normalization, residual (skip) connections
Training loss↓ validation loss↑OverfittingDropout, regularization, augmentation, early stopping
Both losses are highUnderfittingIncrease model capacity, train longer, enrich features
Training stops with OOMBatch or model too largeReduce batch size
Hidden-layer output stays at 0Dead ReLUReplace with Leaky ReLU, etc.

When Training Neural Networks on AWS

SituationChoiceReason
You want to run your own TensorFlow/PyTorch training scriptSageMaker Script ModeRuns your code as-is in a managed training container
You don't want to build per-framework-version environments yourselfDeep Learning Containers (DLC)Prebuilt managed images
Searching hyperparameters such as learning rate and batch sizeAutomatic Model TuningEfficient search through Bayesian optimization
Deep learning training that needs GPUsml.p / ml.g instance familiesFor GPU-accelerated training
Starting quickly from a pretrained modelSageMaker JumpStartProvides pretrained models and fine-tuning scripts

In the next note, we cover the CNN (convolutional neural network), which redesigns this neural network for images, and the distinctions among computer vision tasks.

📖 Glossary

  • Perceptron: The smallest-unit neuron of a neural network, which adds a bias to the weighted sum of inputs and passes it through an activation.
  • Weight / bias: Parameters adjusted by training. The weight is the importance of an input, and the bias shifts the decision boundary in parallel.
  • Activation function: A function that injects nonlinearity between layers. Without it, even a deep network is the same as a linear model.
  • Vanishing gradient: A phenomenon where the product of derivatives in backpropagation converges to 0, so the earlier layers do not learn.
  • Dead ReLU: A neuron that receives only negative inputs and always outputs 0. Its gradient is 0, so it never revives.
  • Forward pass: The computation in the direction that passes the input through each layer to produce a prediction.
  • Backpropagation: An algorithm that computes the gradient of the loss by propagating it from output to input using the chain rule.
  • Loss function: A single number summarizing the difference between predictions and answers. The target that training tries to minimize.
  • Cross-entropy: A loss for probability predictions. Binary uses BCE, and multiclass uses categorical cross-entropy.
  • Epoch / batch / iteration: One pass over all the data / the group used for one update / processing one batch (= one update).

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Which is the MOST appropriate output layer activation function for a multiclass (10-class) image classification neural network?

Question 2

What is the main reason training goes poorly when using Sigmoid in the hidden layers of a deep neural network, and what is the usual remedy?

Question 3

What is the representational power of a multilayer neural network with no activation functions at all (only linear)?

Question 4

When training for 5 epochs with 8,000 samples and a batch size of 200, what is the total number of weight updates (iterations)?

Question 5

Which BEST describes the role of backpropagation?

PreviousWeek 6 Comprehensive Review: Algorithm Selection and SageMaker Builtin AlgorithmsWeek 6 · Day 5Next CNN: Convolutional Neural Networks and Computer VisionWeek 7 · Day 2

Official references

  • MLS-C01 official exam page(opens in a new tab)

On this page

  • Key Takeaways
  • When to Reach for Deep Learning
  • The Perceptron: The Smallest Unit of a Neural Network
  • Hidden Layers and the Multilayer Perceptron (MLP)
  • Activation Functions
  • Forward Pass and Loss
  • Loss Function Selection Table
  • Loss and Evaluation Metrics Are Different — Metric Interpretation Table
  • Backpropagation
  • Epoch, Batch, Iteration
  • Batch Size Trade-offs
  • Symptom → Cause → Remedy
  • When Training Neural Networks on AWS
  • Glossary
  • Practice Questions