Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Calculus for Machine Learning & AI: Gradients to Diffusion
Role Play
New
1 students

Calculus for Machine Learning & AI: Gradients to Diffusion

Learn the calculus inside every model: gradients, backpropagation, optimizers, integrals, transformers and diffusion.
Created byOmar Koryakin
Last updated 11/2026
English
ArabicBangla

What you'll learn

  • Read a derivative as slope and sensitivity, and estimate it by nudging an input in NumPy
  • Apply the chain rule to a pipeline of functions and draw its computation graph, forward and backward
  • Compute partial derivatives and the gradient of a loss, and verify them with a numerical gradient check
  • Derive the gradients of squared error, cross-entropy, logistic regression and softmax, and explain why they come out as prediction minus truth
  • Run gradient descent by hand and tune the learning rate, mini-batches, momentum, Adam, schedules and warmup
  • Use Jacobians and the shape rule to work out the gradient of a whole layer, and see why backprop is cheap
  • Work backpropagation by hand on a tiny network, then build a small autograd engine in Python
  • Check your code against autograd in PyTorch and TensorFlow, and write a complete training loop
  • Use integrals to compute probabilities, expectations, entropy and KL divergence, and estimate them with Monte Carlo sampling
  • Diagnose vanishing and exploding gradients, dead units and a bad learning rate from the gradient sizes of a run

Course content

10 sections • 61 lectures • 9h 57m total length
  • Watch a Model Learn9:58
    Watch a real model learn: Greenwheel's ride line starts with both dials at zero and walks downhill on its loss surface until the line settles onto the data and the loss stops falling. You'll see what the loss measures and why training a model means walking downhill.
  • Rate of Change: Reading a Trip9:39
    Follow one Greenwheel commuter from the station dock to the riverside dock and learn the first tool of calculus: the average rate of change, the change in distance divided by the change in time, with its unit. You'll work it out for the whole ride, for the hill stretch and for the last leg.
  • The Derivative: Zoom Until It Is Straight9:45
    A speed camera flashes and asks for a speed at one frozen instant. You'll shrink the window around the flash, watch the average rate settle on one number, zoom until the curve looks straight, and meet the derivative as the slope at a single moment.
  • Slope as Sensitivity9:54
    A cafe nudges the price of a flat white and wants to know how many cups it will lose. You'll see the derivative as a sensitivity, how strongly an output answers a small nudge, and use change equals slope times nudge on the cafe and on Imani's ride line.
  • The Rules You Will Actually Use9:50
    Meet the three derivative shortcuts that carry a model through training: the power rule for the squared miss, the exponential rule for a rumour or a savings jar, and the logarithm rule for a concert's loudness. You'll see each one draw its slope, then check them against nudging.
  • First Notebook: Slopes by Nudging9:38
    Imani measures how fast a dock sensor warms by nudging in Python, and finds that a smaller step is not always a better one. You'll compute a slope with a forward difference, watch the error draw a V against the step size, and learn how to pick a sensible step.
  • Section 1 quiz
  • Explaining to Marisol what 'a model learns' means
  • Assignment 01: One dial, one loss, one slope

Requirements

  • School algebra: solving simple equations and reading a graph
  • A little Python: variables, functions and loops
  • A computer that can run Jupyter notebooks with NumPy, Matplotlib and PyTorch on the CPU
  • No earlier calculus course needed; every idea is taught from scratch
  • Willingness to pause and try each short problem before the answer

Description

This course contains the use of artificial intelligence.

By the end of this course you can read a training loop and say what every gradient in it is doing, build backpropagation from the chain rule line by line, and diagnose a training run that will not learn. You will also know where integrals show up in probability, likelihood, entropy and KL divergence, and what calculus is doing inside embeddings, attention, residual connections, diffusion and low-rank fine-tuning.

The course is built from short lessons of 10 minutes each: 60 lessons, about 10 hours in total, in 10 sections. Every lesson starts from a real situation, such as a speed camera catching one moment, the hot and cold taps of a shower, a hiker in fog, a restaurant bill with tax and tip, or a microphone that squeals. Then you see the idea as a picture, often in 3D, then it gets its name and its formula, and then you work a real example with real numbers. Each lesson pauses so you can try a similar problem yourself before the answer is shown.

Alongside the lessons runs one story. Imani, an ML engineer at a bike-share company, and Theo, a data analyst, train a model on hourly ride data: first a line, then a classifier that predicts whether a dock will run empty within the hour, then a small neural network. You watch the loss fall as the gradient is computed, you see why the learning rate matters, and in the last section you debug three broken runs the way you would at work.

You also get 11 Python notebooks written with NumPy, Matplotlib and PyTorch, plus a TensorFlow comparison. Random seeds are fixed, every notebook runs on a laptop CPU in under two minutes, and the numbers you see in the lessons come from these notebooks. You check a hand derivative against the computer, run a gradient check, build a tiny autograd engine, compare PyTorch and TensorFlow autograd on the same model, and write a full training loop.

This is applied calculus, not a theory course. There are no proofs, no limit theory and no long list of integration techniques. You learn the derivative as slope and sensitivity, the chain rule as multiplying local slopes, the gradient as one arrow that points uphill, the Jacobian as a table of slopes for a whole layer, and the integral as accumulation. Each idea is taught when a model needs it, so you can see why it matters before you meet the formula.

The course is for data scientists, machine learning engineers, analysts and developers who use models every day and want to understand what happens underneath. You need school algebra and a little Python. No earlier calculus course is required.

Who this course is for:

  • Data scientists and analysts who train models and want to understand the gradients behind them
  • Machine learning engineers who want to debug training runs with calculus, not guesswork
  • Software developers moving into machine learning and AI who need the maths that matters
  • Learners who found theory-first calculus courses too long or too far from real models
  • Anyone curious how embeddings, attention and diffusion are trained, with only school algebra and a little Python to start