Frame the answer, seal evaluation, then reason from geometry and counts. Every change below has a visible consequence.
DefineName the job.MechanismShow flow or math.PerturbMove one condition.ConcludeChoose + trade-off.
Notation + reasoning
Translate symbols into a story
one input or feature vector
model governed by parameters
model prediction
parameter choice with the smallest loss
choose the parameter value that minimizes the following quantity
Parameter is learned; hyperparameter is chosen on validation evidence.
Representation is what numbers the learner sees; inductive bias is the solution shape it prefers.
Paradigms: supervised = labels · unsupervised = structure · semi-supervised = few labels + many unlabeled · reinforcement = reward. Bayes error is the irreducible floor.
Perturb: change representation → distances, splits, margins, and learned features can all change.
Evaluation + leakage
Train learns. Validation chooses. Test stays sealed.
Trainfit weights
Train onlyfit scaler
Validatechoose settings
Freezeall choices
Test oncefinal estimate
Deploywatch shift
Actual ↓Pred +Pred −Positive 8 2Negative 2 88
Accuracy96%
Precision80%
Recall80%
F180%
correct positive / negative counts
incorrect positive / negative counts
precision / recall
harmonic mean of precision and recall
fraction of negatives correctly rejected
false-positive rate
CV: rotate validation folds; LOOCV uses . Fit scaler, preprocessing, and feature selection inside each training fold. ROC plots TPR vs FPR; PR plots precision vs recall.
Leakage: selecting depth, threshold, epoch, preprocessing, or features after looking at test results turns that “test” into validation. Obtain a new untouched test set.
Features + trees
Pick the split that removes weighted impurity
examples at the current node
fraction belonging to class
number of classes
child subset for branch
number of examples in that set
information gained by the split
Micro-exampleParent: four positive / four negative, so . After a split, weighted , so .
Features: preprocess → extract → select. Filter scores before a model; wrapper searches with CV. Fit both within folds; univariate filters miss XOR interactions.
Continuous candidates are adjacent-value midpoints. Weight every child; prune/stop depth for variance. Many-valued features inflate IG → use gain ratio.
KNN
Distance → nearest neighbors → vote
norm order: Manhattan at , Euclidean at
number of input features
comparison point whose distance is measured
standardized value of one feature
training mean / standard deviation for that feature
Small : flexible, high variance. Large : smoother, more bias.
Scale first when units differ; choose and metric with validation/CV.
Weight by ; kd-trees help mainly in low dimensions; condensation stores fewer prototypes.
Perturb: scaling can reorder neighbors and flip the vote. If , use exact matches instead of .
SVM
The closest points set the widest margin
boundary orientation and margin scale
boundary offset
penalty for margin violations
slack of one training case
turns the score into the negative or positive class
training input / signed class target
Move a non-support point: boundary normally unchanged.
Constraint first: “catch ≥95%” means tune validation threshold for recall, then compare precision/workload among qualifying choices.
Test set: one final estimate after every decision is frozen. A zero metric denominator is undefined, not confidently zero. Error near the Bayes floor needs better information, not just more capacity.
Recall board 2 · Weeks 5–8
Trace signal forward. Trace blame backward.
Keep a shape ledger and a gradient ledger. Deep learning questions become short when every arrow names what it carries.
ShapeWrite dimensions.ForwardAffine then activate.LossCompare with target.BackwardLocal derivatives.
Neural forward + backprop
One graph, two directions
hidden / output pre-activation values
hidden activation passed to the output
hidden / output trainable weights
hidden / output biases
sigmoid function / binary cross-entropy loss
loss sensitivity entering the output unit
NumbersUsing and gives . For , the output gradient is .
Sigmoid/tanh can saturate; ReLU can die (leaky ReLU keeps a small negative slope). Identical zero-initialized hidden units stay symmetric. Backprop follows each dependency backward.
Optimization + regularization
Optimization fits; regularization generalizes
current loss gradient
momentum accumulator
how much previous momentum is retained
learning rate or update step size
sparsity / shrinkage strengths
Batch=all; stochastic=1; mini-batch=middle. Adam rescales coordinates with gradient moments.
On a quadratic, ; tiny crawls, near-limit oscillates, larger diverges. Warm up, then decay.
zeros; shrinks; elastic net combines. Momentum smooths alternating gradients.
Augment only label-preserving transforms. Dropout off at inference; BatchNorm uses running, not batch, statistics.
Train loss falls while validation rises → restore best validation checkpoint; do not inspect test to choose the epoch.
CNN
Local window, shared weights, shape ledger
dilation; the displayed size rule assumes one
input / output side length
kernel width / stride / zero padding
kernel height / width
input / output channel counts
one learned bias per output filter
Example gives parameters.
Conv32×32×16
Pool 2×216×16×16
Flatten4096
Dense
“Same” at keeps size with ; “valid” means . Keep the floor. Pooling has zero learned parameters.
RNN + LSTM
A recurrent path can fade; a gated highway can carry
input vector at the current sequence step
hidden state exposed to later computation
LSTM memory or cell state
input / recurrent weight matrices
forget / input / candidate / output gate vectors
element-by-element multiplication
Forget keep old memory near
Input write candidate near
Output reveal state near
Numbers gives . With , .
GRU merges forget/input into an update gate and has no separate cell state. Bidirectional needs the whole sequence—invalid for strict streaming. Seq2seq attention selects encoder states instead of one fixed summary.
across many steps → vanishing: gates/attention. → exploding: clip gradients.
Transformers
Match with ; move content with
query / key / value matrices
key-vector width used to scale scores
mask entry for query row and key column
attention-weight matrix / resulting output
normalize each score row to sum to one
Inputtoken embedding + position
Multi-headparallel learned projections
Blockattention → Add&Norm → FFN → Add&Norm
Encoder-only: bidirectional (BERT: masked language modeling + original next-sentence objective).
Decoder-only: causal generation; teacher forcing during training, autoregressive feedback at inference.
Encoder–decoder: decoder cross-attends to encoder ; useful for sequence-to-sequence tasks.
Mask before softmax. Zeroing probabilities afterward breaks row sums and does not renormalize the allowed evidence.
Agreement is not truth. Internal checks become factual verification only when claims are compared with trusted evidence.
DANN
Keep label signal; erase domain signal
feature-extractor parameters
domain-classification loss
strength of the reversed domain signal
gradient with respect to extractor parameters
replace the incoming gradient during backpropagation
Example: labeled hospital A, unlabeled hospital B. Preserve disease evidence while suppressing hospital/scanner cues.
Assumption: source and target share a useful labeling structure. Domain confusion alone must not erase task signal.
Final recall check
Ten checks before you turn the page
Did I name the decision and trade-off?
Is every learned transform train-only?
Did I weight tree children?
Did I scale distance features?
Which points actually set the margin?
Did I preserve tensor dimensions?
Where can the gradient vanish?
Is the causal mask before softmax?
Did I count LoRA as ?
Which exact RAG stage failed?
Reconstruct: close the page and redraw the sealed evaluation flow, forward/backward arrows, masked attention, and six RAG stages. Reopen and mark only omissions.
Bounded to Weeks 1–10; this recall layer does not replace the guide’s worked labs, drills, flashcards, or mock exam. Complete guide →