Repository navigation
Module 02
Curriculum part: Mathematical and Theoretical Foundations
Study level: Foundational
Content status: Substantive introductory chapter; supporting exercises and implementations are maintained separately.
Training is repeated application of the chain rule to a parameterized function. Calculus explains local sensitivity, gradients, curvature and automatic differentiation.
After studying this module, you should be able to:
- Explain the central problem and assumptions of the methods covered.
- Interpret the principal mathematical objects, equations and tensor dimensions.
- Work through a small numerical example without relying on a framework.
- Implement or verify the central operation using NumPy or PyTorch.
- Identify failure modes and select appropriate follow-up material.
Prerequisites: Module 01: vectors, matrices, dot products and matrix multiplication.
The module follows the principle write once, reference everywhere. Foundational derivations are maintained in their primary module; later modules focus on how those ideas are used rather than repeating the full derivation.
A derivative is a local rate of change; the differential approximation is f(x+Δx)≈f(x)+f'(x)Δx. For multivariable scalar functions, the gradient collects partial derivatives and points toward steepest local increase. For f:Rⁿ→Rᵐ, the Jacobian contains all first partial derivatives; the Hessian contains second derivatives for scalar functions and describes local curvature. The chain rule composes derivatives. Backpropagation is reverse-mode automatic differentiation: it propagates vector-Jacobian products from a scalar loss back through the computational graph. Finite differences provide a numerical check, not the preferred training derivative.
A compact form of the central operation is:
∇f=(∂f/∂x₁,…,∂f/∂xₙ)ᵀ; Jᵢⱼ=∂fᵢ/∂xⱼ; Hᵢⱼ=∂²f/(∂xᵢ∂xⱼ). For f(x,y)=x²+3xy, ∇f=(2x+3y,3x). Gradient descent: θ←θ−η∇L(θ).
The equations above define the main computational objects. When implementing them, specify tensor shapes, reduction axes, normalization conventions and whether a loss is summed or averaged. Those details determine the actual computation.
At (x,y)=(1,2), f=7 and ∇f=(8,3). With η=0.1, one gradient step gives (0.2,1.7). This is a local update, not a guarantee of a global minimum in a non-convex objective.
Use the example as a check on notation and implementation. Change one input at a time and verify how the output changes; this is often more informative than immediately moving to a large dataset.
flowchart TD
A[Define the problem and data] --> B[Identify mathematical objects]
B --> C[Write equations and tensor shapes]
C --> D[Work through a small numerical case]
D --> E[Implement the operation]
E --> F[Verify outputs and gradients]
F --> G[Evaluate limitations and connect to later modules]
Derive gradients for affine, quadratic, sigmoid and softmax functions. Compare analytical derivatives with central finite differences in float64. In PyTorch, call backward on a scalar loss, inspect gradients, and clear them between independent steps.
A good implementation sequence is:
- Write the operation in plain mathematical notation.
- Calculate a tiny example by hand.
- Implement the operation with NumPy.
- Compare against a trusted PyTorch operation.
- Add shape and numerical assertions.
- Only then run a larger experiment.
See the implementation roadmap for a module-specific progression.
Jacobian orientation depends on row/column conventions. Too-small finite-difference steps amplify round-off; too-large steps violate the local approximation. Stochastic layers and nondeterministic operations complicate gradient checks.
Study Hessian-vector products, Gauss–Newton approximations, Fisher information, implicit differentiation, higher-order autodiff and differentiable optimization.
These are extensions beyond the minimum conceptual foundation. Treat them as directions for further reading or experiments, not as claims that an implementation or benchmark is already complete.
This module is best studied as one integrated chapter; the lesson map divides the reading sequence without duplicating the theory.
- Lesson map — recommended reading order.
- Numerical exercises and practice — problems to test understanding.
- Implementation roadmap — coding progression.
- Research extensions — selected directions beyond the core.
- Module 06: Loss Functions, Gradient Descent and Empirical Risk Minimization — see how this concept is used in a later architecture or research setting.
- Module 07: Feedforward Neural Networks and Backpropagation — see how this concept is used in a later architecture or research setting.
- Module 08: Deep Network Optimization and Loss Landscapes — see how this concept is used in a later architecture or research setting.
- Module 09: Weight Initialization, Normalization and Gradient Flow — see how this concept is used in a later architecture or research setting.
- Module 20: Diffusion Models and Denoising Diffusion Probabilistic Models — see how this concept is used in a later architecture or research setting.
The original course material is the primary basis for the course topics in this curriculum. Mathematical prerequisites are included to make the course topics understandable from first principles. Additional modern methods are identified as extensions where appropriate. The chapter does not imply that every proposed coding exercise or research experiment has already been executed.
These sources provide canonical starting points for the concepts in this chapter. They are not a claim that every extension listed above is covered by the original course material.
- Stewart, J. (2015). Calculus: Early Transcendentals (8th ed.). Cengage.
- Baydin, A. G., et al. (2018). Automatic differentiation in machine learning: a survey. Journal of Machine Learning Research, 18(153), 1–43.
- Explain the main ideas in your own words.
- Re-derive the central equations and check dimensions.
- Solve the worked example independently.
- Complete at least one numerical exercise.
- Implement and verify the central operation.
- Explain at least two limitations or failure modes.
- Follow the cross-module links relevant to your learning path.
Next: Continue to the lesson map or return to the curriculum map.
🏠 Home · 🗺️ Curriculum · 🧭 Learning paths · ❓ Question bank · 📖 Glossary · 📚 References · ✏️ Contributing
🏠 Home · 🗺️ Curriculum · 🧭 Learning paths
❓ Question bank · 📖 Glossary · 📚 References
Jump to module:
01 02 03 04 05 06 07 08 09 10 11 12
13 14 15 16 17 18 19 20 21 22 23 24