2100: Calculus for Deep Learning¶
Build the mathematical engine of deep learning — tensor algebra by hand in PyTorch, then the chain rule as a computational graph you can differentiate.
Contents¶
- Module Overview
- Learning Objectives
- Module Contents
- Learning Path
- Prerequisites
- Assessment
- Related Modules
- Time Commitment
- Resources
- Tips for Success
- Common Pitfalls
- Summary
- References
- Next Steps
Module Overview¶
This module covers the essential calculus concepts that power modern deep learning systems. From tensor algebra through backpropagation to loss-landscape geometry, you'll build the mathematical foundation needed to understand how neural networks learn.
Why This Matters:
- Every neural network training run relies on gradient descent and backpropagation
- Understanding derivatives enables you to debug optimization problems
- Tensor operations are the building blocks of all modern ML frameworks
- Strong calculus intuition helps with model architecture design
Learning Objectives¶
After completing this module, you will be able to:
- Tensor Operations: Manipulate multi-dimensional arrays and understand broadcasting
- Automatic Differentiation: Grasp how frameworks compute gradients automatically
- Backpropagation: Derive and implement the backward pass for neural networks
- Optimization Intuition: Understand gradient flow, vanishing/exploding gradients
- Chain Rule Mastery: Apply chain rule to complex computational graphs
- Loss Landscape Geometry: Read curvature, saddles, and convexity off the Hessian
Module Contents¶
Each lesson is written around runnable code — work through the examples, don't just read them.
Lesson 2101 — Tensors, the Language of Deep Learning¶
2101: Tensor Algebra and Linear Algebra for AI
- Tensor shapes and operations (element-wise, matrix multiplication, broadcasting)
- Einstein summation — from dot products to scaled dot-product attention in one notation
- Reductions, SVD/PCA, reshaping, slicing, and memory layout
- GPU tensors, tensor cores, and mixed precision
- AI patterns: linear layers, convolution as einsum, layer normalization
Lesson 2102 — The Backpropagation Engine¶
2102: Backpropagation and Automatic Differentiation
- Chain rule for scalars and tensors, forward and backward passes on computational graphs
- How PyTorch autograd works under the hood
- Common gradient patterns (linear layer, ReLU, softmax + cross-entropy)
- Vanishing and exploding gradients — and the standard fixes
- Hessians, gradient accumulation, and best practices (zeroing, inference mode, checkpointing)
Lesson 2103 — Reading the Loss Landscape¶
- The Hessian's diagonal entries as curvatures — sign patterns that classify minima, maxima, and saddles
- The flat-direction trap: GD escapes the saddle in 25 steps while the flat axis needs 1,151 steps to fall to a tenth
- Why high dimensions are saddle country — the sign-sampling counting argument
- Convexity, tested pointwise: when any local minimum is the global answer
- The optimizer campaign: momentum as inertia, carrying 28 of 495 shallow-basin starts into the deep well
Learning Path¶
- Verify readiness with 2100: Calculus for Deep Learning - Prerequisites
- 2101: Tensor Algebra and Linear Algebra for AI — shapes, broadcasting, einsum, GPU tensors
- 2102: Backpropagation and Automatic Differentiation — chain rule, autograd, the backward pass
- 2103: Loss Landscape Geometry — curvature, saddles, convexity, momentum
- Check understanding with the 2100: Calculus - Quiz
- Apply it with the 2100: Calculus - Practice exercises
Prerequisites¶
Required:
- Vectors and matrices — dot products and matrix multiplication at the by-hand level
- Derivatives and the chain rule — single-variable calculus is enough to start
- Python programming fundamentals, ideally with some NumPy
Helpful:
- A CUDA GPU for the 2101 GPU sections — every code example runs on CPU, and the GPU blocks are clearly marked and optional
- PyTorch installed — 2101 starts tensor knowledge from zero
Review: 2100: Calculus for Deep Learning - Prerequisites for detailed requirements with runnable self-check examples.
Assessment¶
Knowledge Check¶
- 2100: Calculus - Quiz — 20 questions across the module's lessons, 80% to pass
Practice Exercises¶
- Format: Hands-on coding exercises
- Duration: 2-3 hours
- Topics:
- Compute derivatives analytically and with autograd
- Run gradient descent in 1D and 2D
- Apply the chain rule to composite functions
- Location: 2100: Calculus - Practice
Related Modules¶
- 2200: Deep Learning Frameworks — implement the tensor operations and autograd you just understood
- 2300: Framework Engineering — build them into working ML systems
- 3100: Attention Architectures — gradient flow through attention layers
- 4100: Low-Bit Quantization — calculus in quantization-aware training
Time Commitment¶
| Activity | Time |
|---|---|
| Reading (2101) | 2 hours |
| Experiments (2101) | 2 hours |
| Reading (2102) | 2 hours |
| Experiments (2102) | 2 hours |
| Reading (2103) | 2 hours |
| Experiments (2103) | 2 hours |
| Quiz | 1 hour |
| Practice | 2-3 hours |
| Total | 15-16 hours |
Resources¶
Essential Reading:
- Mathematics for Machine Learning (Deisenroth, Faisal & Ong) — free PDF; the linear algebra and vector calculus chapters map directly onto this module
- Deep Learning (Goodfellow, Bengio & Courville) — Chapter 2 (Linear Algebra), free to read online
- CS231n Notes (Stanford) — "Backpropagation, Intuitions" and the gradient-check walkthroughs
Optional:
- The Matrix Calculus You Need For Deep Learning (Parr & Howard) — the vector-chain-rule reference Lesson 2102 leans on
- Essence of Linear Algebra (3Blue1Brown) — geometric intuition for everything in 2101
- Essence of Calculus (3Blue1Brown) — derivatives and the chain rule, visualized
Tips for Success¶
- Don't skip the math: Understanding derivatives helps debug models
- Implement from scratch: Build a simple autograd before trusting frameworks
- Visualize gradients: Print shape and value at every stage of a backward pass
- Practice chain rule: It's the foundation of backpropagation
- Connect to code: Map every equation to a PyTorch operation and run it
Common Pitfalls¶
- Getting lost in notation: Focus on concepts, not just symbols
- Ignoring dimensionality: Always track tensor shapes during operations
- Skipping manual implementation: Using frameworks too early limits understanding
- Not checking gradients: Verify autograd against finite differences when debugging
Summary¶
- This module is the mathematical core of Phase 2: tensor algebra first, then backpropagation — closed by a quiz and hands-on practice.
- Everything is runnable: each lesson's examples execute offline on CPU with PyTorch, GPU sections marked and optional.
- Plan for 15-16 hours (12 hours lessons + 1 hour quiz + 2-3 hours practice).
- These three lessons are the prerequisite chain for the rest of Phase 2: 2200 implements what 2101 explains, 2300 engineers what 2102 derives, and every optimizer they run walks the landscapes 2103 maps.
References¶
Related Documents¶
- 2101: Tensor Algebra and Linear Algebra for AI — shapes, broadcasting, einsum, GPU tensors
- 2102: Backpropagation and Automatic Differentiation — chain rule, autograd, gradient patterns
- 2103: Loss Landscape Geometry — curvature, saddles, convexity, and the optimizer campaign
- 2100: Calculus for Deep Learning - Prerequisites — readiness check with runnable self-test examples
- EXP_2101: Tensor Algebra — hands-on tensor exercises
- EXP_2102: Backpropagation Experiment — hands-on backprop exercises
- 2300: Framework Engineering — the next module that builds on this one
External References¶
- Mathematics for Machine Learning — Deisenroth, Faisal & Ong; free PDF
- Deep Learning — Goodfellow, Bengio & Courville; Chapter 2
- CS231n Notes — Stanford; backpropagation intuitions and gradient checks
- The Matrix Calculus You Need For Deep Learning — Parr & Howard
- Essence of Linear Algebra — 3Blue1Brown
- Essence of Calculus — 3Blue1Brown
Next Steps¶
- Not reviewed yet? Start with 2100: Calculus for Deep Learning - Prerequisites and run its self-check examples.
- Work the lessons in order: 2101: Tensor Algebra and Linear Algebra for AI → 2102: Backpropagation and Automatic Differentiation → 2103: Loss Landscape Geometry - Curvature, Saddles, and the Shape of Optimization — each builds on the previous one.
- Close the loop: take the quiz, then the practice exercises.
- Continue to the next module: 2200: Deep Learning Frameworks
Related: 2101: Tensor Algebra and Linear Algebra for AI · 2102: Backpropagation and Automatic Differentiation · 2103: Loss Landscape Geometry · 2200: Deep Learning Frameworks
Experiment: No EXP_21xx overview exists — start from EXP_2101: Tensor Algebra (the hands-on companion to Lesson 2101).