Module 15

Neural Networks and Deep Learning Foundations

How can a neural network learn complex representations and functions by optimizing millions of parameters?

lessons
22
duration
33 h 15 min
concepts
82
available in English
22 / 22
completed by you
0 of 22

Where it fits

Overview

Build deep learning from the ground up. Go from the perceptron to multilayer perceptrons, study expressivity and likelihood-based losses, derive backpropagation by hand, and build scalar and tensor automatic differentiation engines. Then map those ideas to PyTorch and train on a local GPU. The second half treats training as an engineering and scientific task, with minibatches, optimizers, initialization, normalization, regularization, layer-by-layer diagnostics and stability. Finish with mean-field signal propagation, μP and spectral conditions.

Why it matters

GPT-style language models, AlphaZero’s policy and value network, imitation learning policies, diffusion models and quantitative predictors all use the training methods in this module. Deriving gradients, building automatic differentiation, budgeting GPU memory and interpreting loss curves and layerwise norms help you design and debug new architectures. Later modules reuse this training loop, diagnostic dashboard and stability protocol.

Lessons 22

  1. 01Review: from the linear model to the artificial neuronConnect a single neural layer with linear, logistic and softmax regression, and derive stable losses and gradients for batched inputs.Review60 min
  2. 02The perceptron: learning a hyperplane and hitting XORLearn the perceptron rule, prove the Novikoff convergence bound, and investigate the representation limit illustrated by XOR.Core75 min
  3. 03Multilayer perceptrons and forward propagationStacking layers with intermediate nonlinearities gives a multilayer perceptron (MLP). We formalize forward propagation in batch notation, prove that depth collapses to an affine model without nonlinearities, and study how hidden layers transform the space to make the problem linearly separable in the last layer. We conclude with parameter-space symmetries (neuron permutations and ReLU rescaling), which recur in initialization, loss landscapes, and model merging.Core90 min
  4. 04Activation functions: sigmoid, tanh, ReLU, GELU and relativesCompare sigmoid, tanh, ReLU and its variants, SiLU and GELU through their shapes, derivatives, saturation and numerical behavior.Core75 min
  5. 05Expressivity: universal approximation and the value of depthConstruct one-dimensional ReLU approximations, study universal approximation and linear regions, and examine an exact depth separation through compositions of a tent map.Advanced90 min
  6. 06Loss functions and output layersPair output distributions with losses, implement stable logit-based calculations, and study label smoothing and heteroscedastic regression.Core80 min
  7. 07Backpropagation: the chain rule applied to a networkDerive reverse-mode backpropagation for computational graphs and batched layers, then count operations, estimate activation memory and check manual gradients.Core100 min
  8. 08Micro autograd I: a scalar differentiation engine from scratchBuild a scalar autograd engine line by line in the style of micrograd, with a Value class that records the forward graph, topological backward propagation and gradient accumulation, then a small library of neurons, layers and MLPs to train a real classifier.Core110 min
  9. 09Micro autograd II: a tensor micro frameworkThe scalar engine becomes a NumPy tensor micro-framework with VJP rules, broadcasting in backward passes, and saved-tensor choices that determine activation memory. Build layers, an optimizer, and fused cross-entropy, train an MLP on digits, and explain the tensor approach's speedup.Core110 min
  10. 10From your framework to PyTorch: training on the local GPUMap the custom micro-framework to PyTorch, check layerwise gradient parity, and apply MLP training to the local GPU. Relate step time to FLOPs, arithmetic intensity and launch overhead, then build a reproducible training and resumption template. GPUCore100 min
  11. 11Minibatch training: gradient noise and batch sizeMinibatches turn gradients into noisy estimates. Study epochs and shuffling, measure gradient noise during training, examine critical batch size and the steps-versus-examples frontier, and assess learning-rate scaling and large-batch generalization. GPUCore80 min
  12. 12Optimizers in networks: learning rate, warmup and weight decayApply SGD, momentum, AdamW, learning-rate range tests and schedules to networks. Examine warmup, the AdamW decay timescale, parameter groups and fair optimizer comparisons. GPUCore95 min
  13. 13Vanishing and exploding gradientsAnalyze vanishing and exploding gradients through products of layer Jacobians and deep linear networks, examine saturation, weight scale and depth, and implement gradient clipping. GPUCore85 min
  14. 14Initialization: breaking symmetry and preserving varianceDerive forward and backward moment propagation and the Xavier, He, LeCun and orthogonal initializations. Examine symmetry breaking, dynamical isometry and practical output-layer choices. GPUCore85 min
  15. 15Batch normalizationBatch normalization standardizes each channel using minibatch statistics and learns scale and shift. Derive and implement forward and backward passes, examine running statistics and evaluation, and analyze evidence and scale invariance. GPUCore100 min
  16. 16Layer normalization and the normalization familyCompare layer, group, instance and weight normalization through their axes, gradients, invariances and practical choices, including train and evaluation behavior. GPUCore75 min
  17. 17Regularization in networks: dropout, noise and early stoppingStudy inverted dropout, its ensemble and adaptive-regularization interpretations, interaction with batch norm, input noise, early stopping, and controlled regularizer ablations. GPUCore85 min
  18. 18Diagnostics I: reading learning curves and the training recipeDiagnose training by checking initial loss and small-batch overfitting, interpreting learning curves, investigating label noise, and comparing changes under a documented incremental recipe. GPUCore85 min
  19. 19Diagnostics II: activations, gradients and updates layer by layerInstrument networks layer by layer and interpret activation statistics, gradient norms and actual update-to-weight ratios, while examining plasticity and limitations of loss-landscape slices. GPUAdvanced100 min
  20. 20Training stability: loss spikes, divergence and NaNsInvestigate loss spikes, late divergence and non-finite values using curvature, optimizer state, logits and numerical tracing, then compare mitigations and learning-rate sensitivity under controlled budgets. GPUAdvanced95 min
  21. 21Signal propagation in deep networks: mean field, the edge of chaos and dynamical isometryDerive deterministic recursions for signal variance and correlation in infinitely wide random networks. Analyze the ordered and chaotic phases and their boundary, study Jacobian spectra and dynamical isometry, and quantify finite-width deviations with the depth-to-width ratio. Finish with kernel shaping for training deep networks without residual connections or normalization. GPUResearch110 min
  22. 22Feature learning at scale: μP and the spectral conditionStudy how initialization, layer multipliers and learning rates should scale with width to preserve feature learning. Cover abc parameterizations, maximal update parameterization (μP), hyperparameter transfer between widths and the equivalent spectral condition. Examine Muon and finish with depth scaling and open questions. GPUResearch110 min

Module capstone

Your framework versus PyTorch: train, diagnose and scale a deep MLP

The project has two parts. First, use your tensor autodiff framework to train an MLP on MNIST to at least 97% test accuracy. Implement batch normalization, dropout, AdamW and warmup yourself, and check gradient parity with PyTorch layer by layer. Second, use PyTorch and a local GPU to train a 20-layer MLP on Fashion-MNIST with the diagnostic dashboard from Lesson 19. Run ablations for initialization, normalization, dropout, optimizer and warmup with three seeds. Compare the best initialization scale with the critical-point prediction from Lesson 21, then run a μP learning-rate transfer experiment between widths 256 and 2048. Submit a reproducible report with learning curves, the layerwise dashboard, an ablation table and intervals across seeds.

Check what you already know

  • Derive cross-entropy gradients with respect to the logits and W using batch notation
  • Prove perceptron convergence with the (R/γ)² mistake bound
  • Build a one-hidden-layer ReLU network that interpolates a piecewise-linear function and explain depth separation
  • Derive an output-layer loss from negative log-likelihood and implement numerically stable BCE and cross-entropy from logits
  • Derive matrix-form MLP backpropagation and count the FLOPs in one training step
  • Implement a scalar autodiff engine with topological ordering and gradient accumulation
  • Derive the backward passes for broadcast addition and matrix multiplication and determine what each operation saves
  • Verify gradient parity between your framework and PyTorch and estimate GPU throughput in examples per second for an MLP
  • Explain warmup and choose AdamW weight decay from its time scale 1/(ηλ)
  • Derive He initialization for ReLU from variance propagation
  • Derive the batch normalization backward pass and explain the difference between train and eval mode
  • Diagnose training from the update-to-weight ratio, gradient norms and activation statistics by layer
  • Identify the cause of a loss spike and mitigate it with z-loss, clipping or a β₂ adjustment, measuring learning-rate sensitivity
  • Calculate the critical point χ₁ = 1 for a ReLU or tanh network and relate it to initialization
  • Explain why the optimal learning rate shifts with width under standard parameterization and how μP avoids that shift

References