« Track Overview · Warmup · Hitchhiker's · Deep Dive · Principal Deep Dive · Core Contributor · Staff Notes
Phase 32 — ML & Deep Learning Foundations: TensorFlow/PyTorch, Supervised/Unsupervised/RL & Tuning
Answers these JD lines: "Design, develop, train, and deploy machine learning and deep learning models"; "Strong understanding of supervised, unsupervised, reinforcement learning, and deep learning concepts"; "developing machine learning solutions using TensorFlow or PyTorch"; "Optimize model performance through feature engineering, hyperparameter tuning, and continuous evaluation." Every AI/ML Engineer posting leads with some version of these four sentences — and they are asking about a different skill than the agentic/GenAI phases of this track cover. This phase is that skill: the classic ML practitioner's toolkit, built from first principles.
Why this phase exists
This track teaches you to build agent systems on top of foundation models someone else trained. But the AI/ML Engineer role this phase targets is broader: teams still ship fraud classifiers, churn predictors, demand forecasters, recommender rankers, and anomaly detectors — models you train, on your data, evaluated with your metrics. Interviewers for these roles probe three things the GenAI phases don't: can you place a problem in the ML taxonomy (supervised / unsupervised / self-supervised / reinforcement) and pick the right family; do you actually understand the training loop (forward → loss → backward → step) well enough to debug a flat or diverging loss; and can you run the optimization discipline — feature engineering, evaluation that doesn't lie to you, hyperparameter tuning that doesn't leak the test set.
Three boundaries define the scope:
- This phase is the applied practitioner layer, not the internals layer. MLPs, CNNs, RNNs, and Transformers appear here as a survey — what they are, when to reach for them, what their inductive biases buy. The from-scratch internals (attention math, autograd engines, KV caches, training a transformer) belong to the sibling Senior AI Engineer track and are deliberately not duplicated here.
- The labs are mechanisms, not frameworks. Per this track's Lab Standard,
everything runs in pure Python stdlib — you implement the sigmoid, the gradient, the k-means++
draw, the power iteration, the Bellman update yourself, seeded and deterministic. The point is
that
model.fit(),KMeans().fit(), andloss.backward()stop being incantations. - It composes with the neighboring ML-platform phases. Features at scale are Phase 27; training jobs, registries, and endpoints are Phase 25; experiment tracking, CI/CD, and drift are Phase 26. This phase supplies the modeling knowledge those pipelines exist to serve.
TensorFlow vs PyTorch
The JD says "TensorFlow or PyTorch" — the interview says "compare them." The full mechanism comparison is Warmup §9; this is the decision table.
| PyTorch | TensorFlow (+ Keras) | |
|---|---|---|
| Execution model | define-by-run (eager): the graph is your Python control flow; torch.compile JIT-optimizes it after the fact | eager by default since TF2, but production speed comes from tf.function tracing Python into a static graph |
| Autograd surface | loss.backward() on a dynamic tape; requires_grad per tensor | tf.GradientTape records ops in context; gradients via tape.gradient |
| Model API | nn.Module subclass + explicit training loop you write | Keras Model/Sequential + built-in compile/fit/callbacks; subclassing available when needed |
| Data pipeline | Dataset + DataLoader (workers, samplers, collate) | tf.data (map/shuffle/batch/prefetch as a graph) |
| Distributed | DistributedDataParallel, FSDP; torchrun | tf.distribute strategies (Mirrored, MultiWorker, TPU) |
| Deployment | TorchServe, torch.export/ONNX, ExecuTorch (mobile/edge) | TF Serving (mature, gRPC), TFLite → LiteRT (mobile/edge), TF.js |
| Center of gravity | research, LLM ecosystem, Hugging Face, most new papers | end-to-end production pipelines (TFX), mobile, Google Cloud/TPU |
| Pick it when | you iterate on architectures, live in the open-model ecosystem, want Python-native debugging | you need the hardened serving/mobile path, TFX-style pipelines, or a team already invested in Keras |
Honorable mention: JAX — NumPy-plus-composable-transforms (grad, jit, vmap, pmap),
pure-functional, the research stack behind Gemini-era work at Google; know it exists and why its
functional purity makes distributed training clean. The senior answer to "which one?" is: the
concepts transfer — tensors, autograd, modules, data pipelines, the loop — and the choice is
usually made by the team's serving stack and ecosystem, not by the loop you write.
Concept map
- The problem taxonomy — supervised / unsupervised / self-supervised / reinforcement; what signal supervises each, and which business problems map where (Warmup §1).
- Generalization — bias-variance, under/overfitting, and the regularization toolbox: L1/L2, dropout, early stopping, data augmentation (Warmup §2–3; Labs 01's L2 + early stopping).
- Supervised family — linear/logistic regression, trees and GBMs (XGBoost/LightGBM), SVMs, kNN — each with its loss function and its "when" (Warmup §4; Lab 01 builds the training loop).
- Optimization — gradient descent (batch/SGD/mini-batch), momentum, RMSProp, Adam/AdamW, learning-rate schedules; the forward → loss → backward → step loop (Warmup §5–6; Lab 01).
- Unsupervised family — k-means/k-means++, hierarchical clustering, GMMs/EM, PCA and dimensionality reduction (Warmup §7; Lab 02 builds k-means++ and PCA-by-power-iteration).
- Reinforcement learning — MDPs, value vs policy methods, Q-learning vs SARSA, the exploration-exploitation dilemma, bandits, and the DQN → policy-gradient → PPO/RLHF arc (Warmup §8; Lab 03 builds Q-learning and two bandits).
- Deep learning survey — MLP/CNN/RNN/Transformer inductive biases, activations, initialization, batch/layer norm, backprop intuition — internals deferred to the Senior AI Engineer track (Warmup §10–11).
- The practitioner discipline — feature engineering and leakage (§12–13), evaluation and cross-validation and imbalance-proof metrics (§14), hyperparameter tuning without fooling yourself (§15), reproducibility (§16).
The labs
| Lab | You build | Proves you understand |
|---|---|---|
| 01 — Supervised Training Loop | logistic regression by mini-batch gradient descent: stable sigmoid, BCE + L2, analytic gradients verified by finite differences, seeded shuffle, early stopping, confusion-matrix metrics | what .fit() and loss.backward() actually do; why the gradient check is the ground truth |
| 02 — Unsupervised: k-means + PCA | k-means++ init, Lloyd's loop with monotone inertia and empty-cluster repair, silhouette score; PCA via covariance + power iteration + deflation, projection and reconstruction error | learning structure without labels; why init decides k-means' fate; eigenvectors without linalg.eig |
| 03 — Reinforcement Learning | GridWorld MDP, tabular Q-learning with ε-greedy exploration, Bellman-residual convergence proof, optimal-path extraction; ε-greedy and UCB1 bandits | delayed credit assignment, off-policy learning, and exploration-exploitation — the concepts under DQN, MCTS, and RLHF |
Integrated scenario (how this shows up at work)
Your team ships a churn model. You frame it (supervised, binary classification), engineer features from raw events without leaking the future (Phase 27 scales this up), and train a baseline logistic regression before anything fancy — Lab 01's loop, now with a framework. Evaluation is a proper train/val/test split with PR-AUC because churners are 7% of the base (accuracy would score 93% for a model that predicts "nobody churns"). You tune with random search over a log-scale learning-rate range, on the validation set only, and early-stop each trial. Segmenting users for the retention team is Lab 02's k-means (on PCA-reduced features); choosing which retention offer to show each segment is Lab 03's bandit, allocating traffic adaptively instead of a fixed A/B split. The trained model ships through Phase 25's registry and endpoints, with Phase 26's drift monitoring watching the feature distributions. Every step is this phase; nothing in it is a GenAI problem.
Deliverables checklist
-
Lab 01 green under
LAB_MODULE=solution pytestand your ownlab.py(27 tests); you can derive thep − ygradient on a whiteboard. - Lab 02 green (28 tests); you can explain why k-means++ beats uniform init and how power iteration finds an eigenvector.
- Lab 03 green (28 tests); you can state what makes Q-learning off-policy and prove it from your own test.
- You can fill in the TensorFlow-vs-PyTorch table from memory and defend a pick for a given team.
- You can name the loss function for each supervised family member without hesitating.
- You can say why tuning on the test set is fraud, and what the validation set is for.
Key takeaways
- The taxonomy is the first interview filter. Supervised learns from labels, unsupervised from structure, self-supervised from the data's own content, RL from delayed reward. Placing a problem correctly is the first thing an ML engineer does — and the first thing they're asked.
- The training loop is one shape everywhere: forward → loss → backward → step, plus a
validation check. Lab 01 in pure Python,
nn.Module+ optimizer in PyTorch,model.fitin Keras — same loop, different amounts of sugar. - Generalization is the actual job. Anything can memorize a training set; bias-variance, regularization, and honest validation are what make a model worth deploying.
- Evaluation lies unless you make it honest: split before you look, cross-validate when data is small, use precision/recall/PR-AUC under imbalance, and never let the test set influence any decision.
- TensorFlow vs PyTorch is an ecosystem decision, not a religion. Eager vs graph,
nn.Modulevs Keras, TorchServe vs TF Serving — know the table, then say "the concepts transfer." - The senior framing: "I can take a business problem, place it in the taxonomy, build and train a baseline, evaluate it without fooling myself, and tune it systematically — and I know when the answer is a GBM on tabular features, not a foundation model."