Stage 1 Course • Complete Curriculum

Stage 1: AI Foundations & Applied Math

The definitive, zero-cost engineering roadmap to the mathematical machinery behind Machine Learning, Deep Learning, and Modern LLMs. Master Linear Algebra, Multivariate Calculus, Probability, Information Theory, Vectorized Python, and every curated free textbook, course, and interactive tool available today.

Complete Course Estimated: 4–8 Weeks (Self-Paced) 100% Free Resources 6 Core Modules + Simulators

Why Applied Math is Non-Negotiable in AI

Many tutorials treat AI as a black box: import model; model.fit(X, y). But when an LLM hallucinates, an embedding model collapses into uniform vectors, loss explodes into NaN, or gradient descent oscillates uncontrollably, high-level API knowledge fails.

In Stage 1, you learn the exact four mathematical pillars that govern all AI: Linear Algebra (how data and weights are represented in high-dimensional spaces), Multivariate Calculus (how models compute errors and optimize via backpropagation), Probability & Statistics (how systems quantify uncertainty and generalize), and Vectorized Scientific Computing (how GPUs calculate trillions of matrix operations per second).

01. AI Foundations & Computational Intelligence

Before diving into equations, you must build the conceptual ontology of artificial intelligence: how computational systems perceive their environment, structure state spaces, search for optimal policies, and transition from hardcoded rules to learned representations.

Classical Symbolic AI (GOFAI)

Rule-Based & Search

Knowledge is explicitly hand-coded by human experts via predicate logic, if-then heuristics, and state-space tree traversal.

  • Deterministic, verifiable, and highly explainable.
  • Search algorithms: Depth-First (DFS), Breadth-First (BFS), A* Heuristic Search.
  • Limitation: Brittleness in messy, high-dimensional perceptual domains (vision, speech).
Statistical & Connectionist AI

Learning from Experience

Rules are not written; parameterized functions learn weights automatically from raw data by minimizing an empirical risk objective.

  • Probabilistic inference and continuous latent representations.
  • Handles raw sensory noise, natural language ambiguity, and computer vision.
  • Scales with compute and data volume (Sutton's "Bitter Lesson").
Concept 1.1

Rational Agents

The standard model (Russell & Norvig): An agent perceives its environment through sensors and takes actions through actuators to maximize its expected performance measure.

Concept 1.2

The AI Hierarchy

AI (any rational system) ⊇ Machine Learning (learning statistical patterns) ⊇ Deep Learning (multi-layer representations) ⊇ Generative AI & LLMs.

Concept 1.3

Three Learning Paradigms

Supervised (labeled pairs $(x, y)$), Unsupervised (discovering latent density $p(x)$ and clusters), and Reinforcement Learning (trial-and-error policy $\pi(a|s)$ for rewards).

Concept 1.4

Inductive Bias & Generalization

Why models work on unseen data: The structural assumptions baked into an architecture (e.g., translation invariance in CNNs, permutation equivariance in Transformers).

02. Linear Algebra for AI & Deep Learning

Linear Algebra is the language in which all AI algorithms are expressed. Every token in Claude or GPT is a vector in 4,096-dimensional space. Every layer in a neural network is a linear transformation $y = Wx + b$. Attention in Transformers is a sequence of dot products.

Core Transformation: Affine Layer Forward Pass $W \in \mathbb{R}^{m \times n}, \mathbf{x} \in \mathbb{R}^n$
$$\mathbf{z} = \mathbf{W}\mathbf{x} + \mathbf{b} = \begin{bmatrix} w_{11} & w_{12} & \cdots & w_{1n} \\ w_{21} & w_{22} & \cdots & w_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ w_{m1} & w_{m2} & \cdots & w_{mn} \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} + \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_m \end{bmatrix}$$
Matrix multiplication maps an input representation $\mathbf{x}$ from an $n$-dimensional coordinate space into an $m$-dimensional feature space through rotation, scaling, and shear, followed by a bias translation $\mathbf{b}$.
Semantic Similarity: Dot Product & Cosine Metric Basis of Vector Databases & Self-Attention
$$\mathbf{u} \cdot \mathbf{v} = \sum_{i=1}^d u_i v_i = \|\mathbf{u}\|_2 \|\mathbf{v}\|_2 \cos(\theta) \implies \text{Cosine}(\mathbf{u}, \mathbf{v}) = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\|_2 \|\mathbf{v}\|_2}$$
When vectors are unit-normalized ($\|\mathbf{u}\|_2 = 1$), their dot product equals the cosine of the angle between them. If $\theta = 0^\circ$, $\cos(\theta) = 1$ (identical semantic meaning); if $\theta = 90^\circ$, $\cos(\theta) = 0$ (orthogonal, unrelated concepts).
LA.1

Vectors, Matrices & Tensors

Scalars ($0\text{D}$), Vectors ($1\text{D}$), Matrices ($2\text{D}$), and Tensors ($n\text{D}$, e.g. batch size $\times$ sequence length $\times$ hidden dimension). Dimension broadcasting and memory strides.

LA.2

Linear Independence & Span

A set of vectors is linearly independent if no vector can be expressed as a linear combination of others. The span defines the accessible subspace. Basis vectors form the coordinate grid.

LA.3

Matrix Inverses & Determinants

The determinant $\det(A)$ represents the scaling factor of volume under transformation. A matrix is invertible ($A^{-1}$ exists) if and only if $\det(A) \neq 0$ and it has full rank.

LA.4

Eigenvalues & Eigenvectors

Directions where a linear transformation acts merely as a scalar scaling: $A\mathbf{v} = \lambda\mathbf{v}$. Fundamental to Principal Component Analysis (PCA), PageRank, and spectral graph theory.

LA.5

Singular Value Decomposition (SVD)

Factorizing any real matrix $A = U \Sigma V^T$. SVD enables low-rank matrix approximation, foundational to LoRA (Low-Rank Adaptation) for fine-tuning billions of LLM parameters efficiently.

LA.6

Vector Norms ($L_1, L_2, L_\infty$)

$L_1$ norm ($\sum |x_i|$, Manhattan distance) induces sparsity (Lasso regression). $L_2$ norm ($\sqrt{\sum x_i^2}$, Euclidean distance) prevents runaway weight growth (Weight Decay / Ridge).

03. Multivariate Calculus & Optimization

If Linear Algebra provides the skeleton of AI, Calculus is the heartbeat. Calculus determines how a network measures its error and updates millions or billions of parameters via the multivariate chain rule.

Optimization Engine: Gradient Descent Update $\alpha$ = Learning Rate
$$\boldsymbol{\theta}_{t+1} = \boldsymbol{\theta}_t - \alpha \nabla_\theta \mathcal{L}(\boldsymbol{\theta}_t) = \boldsymbol{\theta}_t - \alpha \begin{bmatrix} \frac{\partial \mathcal{L}}{\partial \theta_1} \\ \frac{\partial \mathcal{L}}{\partial \theta_2} \\ \vdots \\ \frac{\partial \mathcal{L}}{\partial \theta_d} \end{bmatrix}$$
The gradient vector $\nabla \mathcal{L}$ points in the direction of steepest ascent of the loss landscape. By taking a step in the negative direction scaled by $\alpha$, we iteratively descend toward a local or global minimum.
The Engine of Backpropagation: Multivariate Chain Rule Reverse-Mode Automatic Differentiation
$$\frac{\partial \mathcal{L}}{\partial \mathbf{W}^{(l)}} = \frac{\partial \mathcal{L}}{\partial \mathbf{a}^{(L)}} \cdot \frac{\partial \mathbf{a}^{(L)}}{\partial \mathbf{z}^{(L)}} \cdots \frac{\partial \mathbf{z}^{(l+1)}}{\partial \mathbf{a}^{(l)}} \cdot \frac{\partial \mathbf{a}^{(l)}}{\partial \mathbf{z}^{(l)}} \cdot \frac{\partial \mathbf{z}^{(l)}}{\partial \mathbf{W}^{(l)}} = \boldsymbol{\delta}^{(l)} (\mathbf{a}^{(l-1)})^T$$
Backpropagation calculates exact parameter gradients in a single backward pass by caching intermediate forward activations $\mathbf{a}$ and propagating error sensitivities $\boldsymbol{\delta}$ backward from output to input.
CALC.1

Partial Derivatives & Gradients

Computing the sensitivity of a scalar loss function with respect to one variable while holding all other variables constant. The gradient vector collects all partial derivatives.

CALC.2

Hessian Matrix & Curvature

The square matrix of second-order partial derivatives $H_{ij} = \frac{\partial^2 \mathcal{L}}{\partial \theta_i \partial \theta_j}$. Determines local curvature: positive definite (local minimum), negative definite (maximum), or indefinite (saddle point).

CALC.3

SGD, Momentum & RMSprop

Stochastic Gradient Descent (SGD) uses single or mini-batch samples. Momentum adds an exponential moving average of past gradients to dampen oscillations across ravine-shaped landscapes.

CALC.4

Adam & AdamW Optimizers

Adam tracks both first moments (mean gradient) and second moments (uncentered variance). AdamW correctly decouples weight decay $L_2$ regularization from the adaptive gradient moment updates.

04. Probability, Statistics & Information Theory

Real-world data is inherently noisy, incomplete, and stochastic. Probability theory formalizes reasoning under uncertainty, while Information Theory quantifies surprise, compression, and loss.

The Foundation of Statistical Inference: Bayes' Theorem Updating Beliefs with Evidence
$$P(\theta | D) = \frac{P(D | \theta) P(\theta)}{P(D)} = \frac{P(D | \theta) P(\theta)}{\int P(D | \theta') P(\theta') d\theta'} \iff \text{Posterior} \propto \text{Likelihood} \times \text{Prior}$$
Bayesian reasoning enables updating parameter beliefs $\theta$ upon observing dataset $D$. Maximum A Posteriori (MAP) incorporates priors, whereas Maximum Likelihood Estimation (MLE) maximizes the likelihood alone.
Information Theory: Shannon Entropy & Cross-Entropy Loss Standard Loss for Classification & LLM Pretraining
$$H(p, q) = -\sum_{x} p(x) \log q(x) = H(p) + D_{KL}(p \parallel q)$$
Minimizing the cross-entropy loss between the true label distribution $p$ and the model's predicted softmax distribution $q$ is mathematically equivalent to minimizing the Kullback-Leibler (KL) divergence to zero.
STAT.1

Probability Distributions

Bernoulli (coin flip), Categorical/Multinomial (tokens in vocabulary), Gaussian/Normal (weights, sensor noise, latent VAE spaces), and Uniform distributions.

STAT.2

Expectation & Covariance

Expected value $\mathbb{E}[X] = \int x p(x) dx$, variance $\text{Var}(X) = \mathbb{E}[(X - \mu)^2]$, and covariance matrix $\Sigma = \mathbb{E}[(X - \mu)(X - \mu)^T]$ measuring linear associations.

STAT.3

MLE vs MAP

Maximum Likelihood finds parameters that make observed data most probable: $\theta_{MLE} = \arg\max_\theta \sum \log P(x_i|\theta)$. MAP adds regularizing priors: $\theta_{MAP} = \arg\max_\theta [\log P(D|\theta) + \log P(\theta)]$.

STAT.4

KL Divergence & VAEs

$D_{KL}(P \parallel Q) = \sum P(x) \log \frac{P(x)}{Q(x)}$. Measures how distribution $Q$ differs from reference $P$. Critical in Variational Autoencoders (ELBO loss) and RLHF policy constraint penalties.

05. Applied Python & Vectorized Computing Stack

Mathematical formulas on paper must run efficiently on Silicon. Pure Python loops run in software interpreters; NumPy and PyTorch bypass Python overhead by compiling vector operations down to optimized C and CUDA SIMD primitives.

Vectorized vs Naive Loop Performance in Python Speedup: ~80x to 150x
import numpy as np
import time

N = 10_000_000
a = np.random.randn(N).astype(np.float32)
b = np.random.randn(N).astype(np.float32)

# --- Naive Python Loop ---
start = time.perf_counter()
dot_naive = sum(x * y for x, y in zip(a, b))
t_naive = time.perf_counter() - start

# --- Vectorized NumPy Dot Product ---
start = time.perf_counter()
dot_vectorized = np.dot(a, b)  # Uses BLAS AVX2 / AVX-512 SIMD
t_vectorized = time.perf_counter() - start

print(f"Naive Python Loop: {t_naive:.4f}s")
print(f"NumPy Vectorized:  {t_vectorized:.4f}s")
print(f"Vectorization Speedup: {t_naive / t_vectorized:.1f}x faster!")

Micro-Capstone: Building a Perceptron from Pure Scratch

In this stage capstone, you implement an entire binary classification neuron without using Scikit-Learn or PyTorch, using only standard NumPy vector operations.

pure_perceptron.pyPure NumPy Implementation
import numpy as np

class PurePerceptron:
    def __init__(self, lr=0.01, epochs=50):
        self.lr = lr
        self.epochs = epochs
        self.w = None
        self.b = 0.0

    def fit(self, X, y):
        n_samples, n_features = X.shape
        self.w = np.zeros(n_features)
        
        for epoch in range(self.epochs):
            for i in range(n_samples):
                # Forward Pass: Linear combination
                linear_output = np.dot(X[i], self.w) + self.b
                # Step Activation: 1 if >= 0 else 0
                y_pred = 1 if linear_output >= 0 else 0
                # Error calculation & Perceptron update rule
                error = y[i] - y_pred
                if error != 0:
                    self.w += self.lr * error * X[i]
                    self.b += self.lr * error

    def predict(self, X):
        linear_output = np.dot(X, self.w) + self.b
        return np.where(linear_output >= 0, 1, 0)

06. Interactive Mathematical Simulators

Reinforce your mathematical intuition with real-time interactive calculators and visualizers directly inside this page.

1. Vector Embedding Cosine Similarity Calculator

Input two 3-dimensional embedding vectors to calculate their dot product, norms, and cosine angle:

Click 'Compute Cosine Similarity' to evaluate dot product and cosine metric.
2. Gradient Descent Convergence Simulator

Minimize $f(x) = x^2 - 4x + 7$ (derivative $f'(x) = 2x - 4$, analytical minimum at $x=2.0$). Test how learning rate $\alpha$ causes convergence, oscillation, or divergence:

Click 'Run Gradient Descent' to observe the step-by-step optimization trajectory.
3. Bayes' Theorem Medical / Spam Test Calculator
Click to compute the true posterior $P(\text{Disease}|+)$ taking the base rate into account.

07. The Master Free Resource Catalog

Every resource listed below is 100% free, globally renowned, verified, and requires no paid subscription. They are organized by topic and pedagogical style.

Linear Algebra Free Resources

Video Series 16 Lessons

Essence of Linear Algebra

Grant Sanderson (3Blue1Brown)

The single best visual introduction to vectors, linear transformations, matrices, determinants, dot products, and eigenvectors in existence.

Watch Free →
MIT OpenCourseWare Full Course

MIT 18.06: Linear Algebra

Prof. Gilbert Strang (MIT)

The legendary MIT course covering the four fundamental subspaces, projection matrices, Gram-Schmidt orthogonalization, eigenvalues, and SVD.

Access MIT OCW →
Interactive Book Web App

Immersive Linear Algebra

J. Ström, K. Åström, T. Enqvist

The world's first linear algebra book with fully interactive 3D WebGL graphics and draggable vectors embedded in every single theorem.

Explore Interactive →
Free Textbook PDF & Notes

Linear Algebra Done Right

Prof. Sheldon Axler

Focuses on understanding vector spaces and linear operators conceptually rather than rote determinant computations.

View Open Access →

Calculus & Optimization Free Resources

Video Series 12 Lessons

Essence of Calculus

Grant Sanderson (3Blue1Brown)

Geometric, intuition-first visualization of derivatives, the chain rule, Taylor series, and limits without mechanical symbol manipulation.

Watch Free →
Free Stanford Book 730 Pages

Convex Optimization

Stephen Boyd & Lieven Vandenberghe

The gold standard textbook used at Stanford. Covers convex sets, duality, KKT conditions, gradient methods, and interior-point algorithms.

Download Free PDF →
MIT OpenCourseWare Full Track

MIT 18.02: Multivariable Calculus

Prof. Denis Auroux (MIT)

Partial derivatives, gradient vectors, directional derivatives, Lagrange multipliers, double/triple integrals, and vector fields.

Access MIT OCW →
Interactive Platform Self-Paced

Khan Academy: Multivariable Calculus

Sal Khan & Grant Sanderson

Step-by-step interactive exercises, practice problems, and instant feedback on partial derivatives, the gradient, and divergence.

Practice on Khan →

Probability & Statistics Free Resources

Harvard University 34 Lectures + Book

Harvard Stat 110: Intro to Probability

Prof. Joe Blitzstein (Harvard)

Harvard's flagship probability course. Covers conditioning, Bayes' rule, random variables, Markov chains, and Poisson processes.

Access Harvard Stat 110 →
Interactive Web App Brown University

Seeing Theory: Visualizing Probability

Brown University Data Science

Award-winning visual interactive introduction to basic probability, compound events, continuous distributions, and Bayesian inference.

Launch Seeing Theory →
Video Library 200+ Videos

StatQuest with Josh Starmer

Josh Starmer (StatQuest)

No-nonsense, highly engaging visual breakdowns of p-values, normal distributions, PCA, ROC/AUC curves, and statistical foundations.

Watch StatQuest →
Open Access Book Green Tea Press

Think Bayes: Bayesian Analysis in Python

Allen B. Downey (Olin College)

A computational approach to Bayesian statistics using pure Python code and simulations instead of heavy abstract integrals.

Read Free Book →

Comprehensive AI Mathematics & Code

Cambridge Univ Press Full 400p PDF

Mathematics for Machine Learning (MML)

Deisenroth, Faisal, Ong

The standard definitive university textbook uniting Linear Algebra, Analytic Geometry, Matrix Decomposition, Calculus, Probability, and Optimization.

Download Official PDF →
Hands-on Code YouTube Masterclass

Neural Networks: Zero to Hero

Andrej Karpathy (ex-OpenAI, Tesla)

Build micrograd (scalar autograd engine), makemore (character-level LM), MLP, and GPT-2 from mathematical scratch in pure Python.

Start Karpathy Series →
MIT Press Book Online Edition

Deep Learning: Applied Math Chapters

Goodfellow, Bengio, Courville

Chapters 2, 3, and 4 cover the exact mathematical foundations (Linear Algebra, Probability, Numerical Computation) required for deep neural nets.

Read DeepLearningBook →
O'Reilly / GitHub Interactive Colab

Python Data Science Handbook

Jake VanderPlas

Exhaustive guide to IPython, NumPy multidimensional arrays, Pandas DataFrames, and Matplotlib data visualization with free Colab notebooks.

Read Online →

08. Recommended Stage 1 Study Schedules

Choose the learning track that best fits your weekly availability and current programming background:

Track 4-Week Fast Track (Experienced Devs) 8-Week Standard Track (Recommended) 12-Week Comprehensive (Zero to Hero)
Week 1–2 Linear Algebra & NumPy vectorization sprint (3Blue1Brown + MML Ch. 2-3). Linear Algebra foundations: Vectors, Matrices, Matrix Multiply, Dot products, and Norms. High School Math refresher, Python programming essentials, and 3Blue1Brown LA series.
Week 3–4 Multivariate Calculus, Autograd, Karpathy Micrograd, and Capstone. Eigenvalues, SVD, PCA, and hands-on NumPy dimensional transformations. Linear Algebra deep dive, Gilbert Strang lectures 1-15, and NumPy array broadcasting.
Week 5–6 — Multivariate Calculus: Gradients, Hessian, Chain Rule, SGD, and AdamW. Multivariate Calculus, partial derivatives, gradient descent intuition, and Khan Academy.
Week 7–8 — Probability, Bayes Rule, MLE, Cross-Entropy loss, and Perceptron capstone. Harvard Stat 110 probability distributions, Bayes Rule, and information theory.
Week 9–12 — — Karpathy Zero-to-Hero, building pure Python micrograd, and Stage 1 Capstone Project.

09. Stage 1 Self-Assessment Quizzes

Validate your foundational understanding before advancing to Phase 2 (Deep Learning & PyTorch).

Q1: If two non-zero embedding vectors $\mathbf{u}$ and $\mathbf{v}$ are perpendicular (orthogonal), what is their dot product and cosine similarity?
A) Exactly 0 (indicating no linear correlation/semantic alignment)
B) Exactly 1 (indicating identical semantic meaning)
C) -1 (indicating opposite semantic meaning)
D) Undefined because vectors cannot be multiplied
Correct! For orthogonal vectors, $\theta = 90^\circ$, so $\mathbf{u} \cdot \mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos(90^\circ) = 0$.
Q2: What is the primary mathematical reason that modern neural network training relies on Reverse-Mode Automatic Differentiation (Backpropagation) instead of Forward-Mode?
A) Forward-mode is less mathematically accurate due to floating point roundoff.
B) Neural networks have millions of inputs/weights but only a single scalar loss function output $f: \mathbb{R}^n \to \mathbb{R}$; reverse-mode computes all $n$ parameter gradients in a single backward pass.
C) Forward-mode cannot calculate the derivative of nonlinear activation functions like ReLU.
D) Reverse-mode eliminates the need for matrix multiplication on GPUs.
Correct! When a function maps $n$ inputs to $m$ outputs, forward-mode costs $O(n)$ passes while reverse-mode costs $O(m)$ passes. Since loss is a single scalar ($m=1$), reverse-mode evaluates all millions of parameter gradients in one single sweep!
Q3: Why is Cross-Entropy loss preferred over Mean Squared Error (MSE) for training classification models with softmax output layers?
A) Cross-entropy is faster to compute on CPUs than MSE.
B) Cross-entropy when paired with softmax avoids vanishing gradients when the prediction is confidently wrong, maintaining strong gradient signals for fast correction.
C) MSE cannot be used on datasets with more than 2 classes.
D) Cross-entropy guarantees finding the global minimum of non-convex neural networks.
Correct! The gradient of cross-entropy with respect to softmax logit $z_i$ simplifies cleanly to $(p_i - y_i)$. When a prediction is completely wrong, the gradient is high ($\approx 1$), driving rapid learning without saturation plateauing.
Ready for the Next Phase?

Once you've internalized these foundational mathematics and written pure NumPy models, you are fully prepared for Phase 2: Deep Learning, PyTorch & Transformers.

Continue to Stage 2: Machine Learning & Deep Learning → View 6-Stage AI Roadmap ↑