Preliminaries

Dive into Deep Learning · §1

Mathematical Foundations and Software Pillars of Deep Learning
tensors · data preprocessing · linear algebra · calculus · automatic differentiation · probability

Why Deep Learning Needs Two New Software Pillars

Motivation

  • Scale breaks scalar code: One 256-image Fashion-MNIST batch holds 200{,}704 pixels; foundation models update 10^9\text{--}10^{12} weights per step.
  • Pillar 1 — Contiguous Tensor Kernels: Pack data into unboxed RAM/VRAM buffers and transform whole batches on SIMD/GPU lanes.
  • Pillar 2 — Reverse-Mode Autograd: Record the execution DAG to obtain all parameter gradients \nabla_{\mathbf{w}} L in a single backward sweep.
  • Statistical Foundation: Bound test-set uncertainty (\sigma/\sqrt{n}) and update beliefs via Bayes’ rule.

Anatomy of a Complete Machine Learning Iteration

The Learning Loop

  • Data to tensors: Parse raw tables, impute gaps without leakage, and pack batches into contiguous float32 / bfloat16 buffers.
  • Forward pass: Project inputs to class logits via batched matrix products \mathbf{O} = \mathbf{X}\mathbf{W} + \mathbf{b}.
  • Loss & backward sweep: Evaluate scalar loss L and propagate Vector–Jacobian Products backward to compute \nabla_{\mathbf{W}} L.
  • Step & statistical evaluation: Update parameters and quantify finite-sample error bars.

Concrete Running Examples Anchoring Each Section

Pedagogical Thread

  • Tensors & linear algebra (images batch): Fashion-MNIST minibatch (256, 1, 28, 28) flattened to \mathbf{X} \in \mathbb{R}^{256 \times 784} and multiplied by \mathbf{W} \in \mathbb{R}^{784 \times 10}.
  • Data preprocessing (house_tiny.csv): 10 homes with missing rooms, categorical roofs, and 500\times scale gaps.
  • Calculus & autograd (line loss & control flow): Fitting L(\mathbf{w}) = \|\mathbf{X}\mathbf{w} - \mathbf{y}\|_2^2 on 3 points and differentiating through Python loops.
  • Probability (coin tosses & screening): 1/\sqrt{n} confidence bands and two-stage Bayesian medical diagnosis.

How to Navigate the Preliminaries and the Math Appendix

Study Guide

  • Hands-on systems focus: Every concept pairs directly with executable framework code for shapes, dtypes, memory aliasing, and gradients.
  • Must-read sections: Even if you know NumPy and calculus, study the autograd section for DAG semantics (detach, in-place hazards) and the probability section for finite-sample standard errors.
  • Deep theoretical proofs: Jump to Chapters 33, 34, and 36 (Math Appendix) for SVD, matrix calculus identities, and MLE asymptotics.