Free Python for AI course
Learn Python from your first line of code to your first call to a language model, with nothing to install.
Learn the math behind AI from arithmetic up: numbers, algebra, vectors and matrices, calculus, probability and statistics, each shown as numbers moving and checked in Python, ending with a network you build and train from the formulas.
One diagram of a model learning, the same in every lesson. Each lesson lights the parts its math is used in; here every part links to the math behind it and the lessons that teach it.
Dataset. Taught in lesson 9, Ratios, rates and proportion, lesson 97, Describing data: center, spread and scale.torch.tensor(x). Taught in lesson 1, Numbers and place value, lesson 7, Decimals and rounding, lesson 12, Bits, bytes and floats: how numbers are stored, lesson 28, Sets, and reading the symbols, lesson 47, Vectors: lists of numbers that point, lesson 53, Matrices: tables of numbers, lesson 65, One-hot vectors and lookup tables: embeddings, lesson 94, Two variables at once: covariance and correlation, lesson 97, Describing data: center, spread and scale.DataLoader(data, batch_size=32). Taught in lesson 2, Multiplying and dividing: groups, lesson 16, Solving equations: keep the balance, lesson 17, Rearranging a formula, lesson 54, Adding, scaling and transposing matrices, lesson 56, Matrix multiplication, lesson 64, Tensors, shapes and broadcasting, lesson 98, Samples, the law of large numbers and the central limit theorem.nn.Embedding(vocab, d). Taught in lesson 41, Coordinates and distance, lesson 42, Angles, degrees and radians, lesson 43, Sine and cosine, lesson 44, Waves: height, speed and shift, lesson 47, Vectors: lists of numbers that point, lesson 51, Angle, cosine similarity and projection, lesson 52, Perpendicular directions: bases and coordinates, lesson 62, Eigenvectors: directions that only stretch, lesson 65, One-hot vectors and lookup tables: embeddings.nn.Linear(d_in, d_out). Taught in lesson 3, Order of operations, and names for numbers, lesson 14, Letters for numbers, lesson 20, Chaining and undoing functions, lesson 21, Straight lines: slope and intercept, lesson 22, Two equations, two unknowns, lesson 50, The dot product, lesson 53, Matrices: tables of numbers, lesson 55, A matrix times a vector, lesson 56, Matrix multiplication, lesson 58, Matrices as movements of space, lesson 59, Determinant and inverse, lesson 66, Sliding dot products: convolution, lesson 110, A layer and a small network as matrices.F.relu(z). Taught in lesson 18, Inequalities and true-or-false, lesson 20, Chaining and undoing functions, lesson 71, Limits: what a value heads toward, lesson 110, A layer and a small network as matrices.F.softmax(q @ k.T / d ** 0.5, dim=-1) @ v. Taught in lesson 57, Identity, diagonal, triangular and symmetric, lesson 87, Counting: choices, orders and groups, lesson 113, Attention as matrix math.logits = model(x). Taught in lesson 24, Exponentials: growth and decay, lesson 65, One-hot vectors and lookup tables: embeddings, lesson 102, Logistic regression: a line that answers yes or no, lesson 110, A layer and a small network as matrices.F.softmax(logits, dim=-1). Taught in lesson 104, Softmax: scores into probabilities.probs. Taught in lesson 6, Multiplying and dividing fractions, lesson 25, Logarithms: the power question, lesson 88, Probability: from counts to chances, lesson 90, Conditional probability and Bayes' rule, lesson 102, Logistic regression: a line that answers yes or no.y. Taught in lesson 4, Numbers below zero, lesson 105, Surprise, entropy and cross-entropy.F.mse_loss(pred, y) or F.cross_entropy(logits, y). Taught in lesson 4, Numbers below zero, lesson 10, Powers and roots, lesson 15, Expanding and factoring, lesson 19, Functions: a rule from input to output, lesson 22, Two equations, two unknowns, lesson 23, Quadratics: bowls and their lowest point, lesson 25, Logarithms: the power question, lesson 26, Sequences and Σ, lesson 27, Weighted and moving averages, lesson 60, Solving systems by elimination, lesson 70, Rates of change, lesson 75, Lowest points and curvature, lesson 92, Expected value, variance and standard deviation, lesson 100, Maximum likelihood, lesson 101, Linear regression: the best line, lesson 105, Surprise, entropy and cross-entropy, lesson 106, KL divergence: how far one distribution is from another.loss.backward(). Taught in lesson 72, The derivative: slope at a point, lesson 73, Derivative rules, lesson 74, The product rule and the chain rule, lesson 77, Partial derivatives, lesson 81, The chain rule with many paths: backpropagation by hand, lesson 83, Jacobians and Hessians, lesson 82, Automatic differentiation: how PyTorch finds every slope, lesson 109, One neuron, start to finish.w.grad. Taught in lesson 49, Length and distance: norms, lesson 78, The gradient, lesson 82, Automatic differentiation: how PyTorch finds every slope.optimizer.step(). Taught in lesson 11, Very big and very small numbers, lesson 16, Solving equations: keep the balance, lesson 24, Exponentials: growth and decay, lesson 27, Weighted and moving averages, lesson 48, Adding and scaling vectors, lesson 49, Length and distance: norms, lesson 76, Standing in for a curve near a point, lesson 79, Gradient descent, lesson 80, Faster descent: momentum and Adam, lesson 109, One neuron, start to finish.model.parameters(). Taught in lesson 61, Independence, span and rank, lesson 63, SVD and PCA: the important directions first, lesson 93, Bernoulli, binomial, uniform and normal.random_split(data, [0.8, 0.2]). Taught in lesson 9, Ratios, rates and proportion, lesson 101, Linear regression: the best line.nn.init.normal_(w, mean=0.0, std=0.02). Taught in lesson 93, Bernoulli, binomial, uniform and normal.loss = loss + lam * (w ** 2).sum(). Taught in lesson 49, Length and distance: norms, lesson 59, Determinant and inverse.torch.multinomial(probs, 1). Taught in lesson 88, Probability: from counts to chances, lesson 91, Random variables and distributions.(pred == y).float().mean(). Taught in lesson 5, Fractions: equal parts, equal fractions, adding, lesson 8, Percentages, lesson 18, Inequalities and true-or-false, lesson 90, Conditional probability and Bayes' rule, lesson 84, Integrals: adding up thin slices, lesson 98, Samples, the law of large numbers and the central limit theorem, lesson 103, Scoring a classifier: confusion table, precision, recall, F1, lesson 99, Is the difference real? Comparing two models.x.numel() * x.element_size(). Taught in lesson 10, Powers and roots, lesson 11, Very big and very small numbers, lesson 12, Bits, bytes and floats: how numbers are stored.x.numel(). Taught in lesson 87, Counting: choices, orders and groups, lesson 89, Combining events: and, or, independent.These eight lines are how most of today's models learn. By the end you'll know the math behind every one of them, and you'll have written the same lines yourself.
model = nn.Sequential(nn.Linear(25, 8), nn.ReLU(), nn.Linear(8, 3))Lesson 110: A layer and a small network as matricesopt = torch.optim.Adam(model.parameters(), lr=1e-3)Lesson 80: Faster descent: momentum and Adamfor x, y in loader:Lesson 64: Tensors, shapes and broadcasting logits = model(x)Lesson 56: Matrix multiplication loss = F.cross_entropy(logits, y)Lesson 105: Surprise, entropy and cross-entropy opt.zero_grad()Lesson 82: Automatic differentiation: how PyTorch finds every slope loss.backward()Lesson 74: The product rule and the chain rule opt.step()Lesson 79: Gradient descentNumbers, algebra, shapes and waves, vectors and matrices, calculus, probability, statistics and information, and a network built from the formulas. Every formula is also on printable formula sheets, one page per module.
All of them are free with no account.
Nothing. It starts from your first line of code.
Finish every lesson and you earn a self-paced certificate of completion, "The Foundation Math For Ai & ML", with its own link you can share or add to LinkedIn. Lessons you skip in the placement test count once you pass their phase's checkpoint.
Yes. There's nothing to pay, here or anywhere in the academy. A free account saves your progress and issues your certificate.
No. The Python in these lessons runs in your browser.
About 95.5 hours in all, at your own pace. Your progress stays where you left it.
That your account recorded every lesson as finished. A self-paced certificate of completion rests on the progress your own devices record as you study. Pass a phase's checkpoint, 12 questions that the academy's server draws and marks itself, and the certificate becomes a verified one that names the checkpoint behind it. Lessons you skip in the placement test count toward a certificate once you pass that checkpoint. There is no proctored exam, and neither kind is an accredited qualification.
Or take the whole course: 575 lessons, from your first line of Python to production AI.
Learn Python from your first line of code to your first call to a language model, with nothing to install.
Learn to write prompts that work reliably, then test them like an engineer: clear instructions, examples, structured output, chains, evals and defenses against prompt injection.
Build retrieval-augmented generation step by step: embeddings, chunking, vector search, grounded answers with sources, and the measurements that tell you whether it works.
Learn how to build AI agents by building one: tools, the agent loop, MCP, permissions, context management and evals, ending with a coding agent that stops when its tests pass.
Go from counting letter pairs to a small GPT you train yourself: tokenizers, attention, transformer blocks and the GPT architecture, written line by line.
Go from your first line of code to working as a Python developer: projects, testing, data, databases, web apps and APIs, all in your browser.
Follow one prompt, "The cat sat", through a language model with every number shown: tokens to IDs, embeddings and positional waves, the attention matrix, the feed-forward layer, and the probability over the next word.
Confident wrong answers, miscounted letters, copying from the prompt, temperature, long prompts that dilute, and a model that never says "I don't know": each behavior reproduced on a tiny GPT with every number printed by code, then the mechanism behind it and the Phase 1 technique it justifies.
Read a model's weights, change them by hand and judge an edit someone else made: deltas, merging, low-rank edits, directions and fact edits on a tiny GPT in your browser. Then replay recorded sessions of an LLM reading, fixing and writing weights, check the published edit of a real open model, and ship a model of your own with its patch, verdict and card. Every number is printed by the lesson's own code, and the method's limits are taught with it.
Take a model from a notebook to a system that stays right: track and reproduce every run, search settings honestly, version data and models, promote through gates, keep training and serving in step, choose batch or online, catch drift, and retrain through a pipeline. Every number is measured by the lesson's own code.
Learn to make any letter of any formula the subject: layers undone in reverse order, fractions, a letter that appears twice, powers, roots, quadratics, logs, inequalities, trigonometry, vectors, matrices, calculus, probability, statistics and the formulas inside AI models, each checked in Python.
Never trained an AI? Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account. Teach it to write
A free account saves your progress across devices and issues your certificate when you finish.