Intuition The one core idea
Training a network means finding the settings (the numbers inside it) that make its mistakes as small as possible — and the way we search is to repeatedly ask "which tiny nudge to the settings makes the mistake smaller?" and take that nudge. Mini-batch gradient descent just answers that question using a small random pile of examples at a time instead of all of them, because a small pile gives a good-enough answer far faster.
This page assumes nothing . Every letter, arrow, and squiggle in the parent note is built here from the ground up, each one leaning on the one before it. Read top to bottom.
Before any math, a picture of what we are even adjusting.
A neural network is a machine: you feed in some input (say the pixels of a photo) and it produces an output (say "cat" or "dog"). Between input and output sit a large pile of numbers — the knobs. Turn the knobs and the machine's behaviour changes. Training = turning the knobs until the machine is usually right.
Definition The symbols for the machine
x — an input example (one photo, one row of data). Picture: the thing you feed in.
y — the correct answer (the "label") that goes with that x . Picture: the sticker on the box.
f — the model , the machine itself: it turns an input into a guess.
θ — (Greek letter "theta") the bundle of all the knob settings . Picture: one giant list of every adjustable number inside f .
f θ ( x ) — read as "the machine f , set up with knobs θ , applied to input x ." It is the model's guess for that input.
Why the topic needs θ : everything in training is about changing θ . It is the variable we optimise. We write f θ (theta as a subscript) to say "the guess depends on the knobs."
We can only improve if we can measure how wrong we are . That measurement is called the loss .
Definition The loss of one example
ℓ ( f θ ( x i ) , y i )
Read left to right: take example number i , get the model's guess f θ ( x i ) , compare it to the true answer y i , and produce one number — small if the guess is good, large if it's bad.
ℓ — (Greek "ell") the loss function , a wrongness-meter.
The subscript i — an index , just a counter naming which example ("the i -th one").
Intuition Why a number and not "right/wrong"?
A yes/no verdict gives us no direction to improve. A number that grows smoothly as the guess gets better tells us not just that we are wrong but how wrong — and later, which way to turn the knobs to be less wrong. That smoothness is the whole reason loss is a number.
We often shorten ℓ ( f θ ( x i ) , y i ) to just ℓ i — "the loss on example i ."
We don't care about one example; we care about all of them. That needs a way to add many things.
Definition The summation symbol
∑ i = 1 N ℓ i = ℓ 1 + ℓ 2 + ℓ 3 + ⋯ + ℓ N
∑ (capital Greek "sigma") means "add up" .
i = 1 under it: start the counter at 1.
N on top: stop when the counter reaches N .
N — the total number of training examples (the size of your whole dataset).
Picture: a conveyor belt carrying N boxes; ∑ is you dropping each box's loss into one bucket.
To turn a total into an average , divide by how many there are:
Why the topic needs J : J ( θ ) is the mountain we are trying to walk down . Its height at position θ is "how wrong the model is overall." Training = find the valley bottom of J .
Now the key move. J depends on the knobs θ , so imagine θ as a location and J as the altitude there. Training is descending this landscape. To descend, we need to know which way is downhill . That direction-finder is the gradient.
Intuition What a gradient
is , in plain words
Stand on a hillside blindfolded. Feel the slope under your feet. The gradient is the arrow pointing in the direction of steepest uphill , and its length says how steep . To go down , walk the opposite way. That is the entire trick of gradient descent.
Definition The gradient symbol
∇
∇ θ J ( θ )
∇ (the upside-down triangle, "nabla" or "del") means "the vector of slopes of J with respect to every knob at once."
The subscript θ : "slopes with respect to the knobs θ " — i.e. how J changes as we wiggle each knob.
The result is itself a list of numbers , one per knob, pointing in the steepest-uphill direction.
Why we need it: it is the only thing that tells us which way to nudge θ . No gradient, no direction, no learning.
Definition Per-example gradient
g i = ∇ θ ℓ i
The steepest-uphill arrow if we only cared about example i . The full gradient is the average of all these arrows:
∇ θ J = N 1 ∑ i = 1 N g i
This "the true gradient is an average" fact is the seed of the whole mini-batch idea.
Knowing the downhill direction, we take a step. How big a step? That is the learning rate.
Definition Learning rate and the update
θ t + 1 = θ t − η g
η (Greek "eta") — the learning rate , a small positive number scaling the step size. Picture: your stride length.
g — whatever gradient estimate we are using (full or from a batch).
The minus sign — we step against the uphill arrow, i.e. downhill.
t — a time counter : θ t is where we are now, θ t + 1 is where we land after one step.
Intuition Why not just jump to the bottom?
The gradient only tells you the slope right here ; it doesn't know where the valley bottom is. So you take a small step, look again, step again. η too big → you overshoot and bounce; η too small → you crawl. See Learning Rate Scheduling .
Mini-batch GD estimates the true average gradient from a random pile . To reason about "estimate" we need three ideas from probability.
Definition The random-sampling vocabulary
B — a mini-batch : a small random subset of the example indices { 1 , … , N } . Picture: a handful grabbed blindly from the bag.
m — the batch size , how many examples are in B . Read m ≪ N as "m is much smaller than N ."
E [ ⋅ ] — the expectation ("expected value"), the long-run average if you repeated the random draw forever. Picture: the value the dice average out to.
Var ( ⋅ ) — the variance , how much the random thing spreads around its average. Picture: wide scatter = big variance, tight cluster = small variance.
"std" = standard deviation = Var , the spread measured in the same units as the thing itself.
Intuition Why these three matter for the topic
Expectation lets us say the batch gradient is right on average (unbiased): E [ g B ] = ∇ J .
Variance measures the noise in one batch's guess — and the parent's headline result is that this noise shrinks like σ / m .
σ (Greek "sigma") names the per-example gradient std: how much individual examples disagree about the direction.
≪ is just a fancy < ."
Why it feels right: both are "less than."
The fix: ≪ means much less than — orders of magnitude (m = 128 vs N = 1 0 7 ). It signals "the batch is a tiny sample of a huge dataset," which is exactly why sampling saves so much work.
One epoch = one full pass through all N examples, chopped into batches of size m . Number of steps per epoch = ⌈ N / m ⌉ , where ⌈ ⋅ ⌉ means round up (the last, smaller batch still counts). Picture: reading a whole book once = one epoch; each page-turn = one batch update.
Sum and average gives objective J
Gradient nabla J points downhill
Update rule with learning rate eta
Random sample batch B of size m
Mini batch gradient descent
Read it as: knobs and loss build the objective J ; J gives a gradient; the gradient plus a step size gives the update rule; sampling plus expectation/variance turn the full gradient into a batch estimate ; both streams meet at mini-batch GD.
Hide the answers, say each out loud, then reveal.
What does θ stand for and what picture goes with it? The bundle of all adjustable knob-settings inside the model; picture a giant list of numbers we turn during training.
What does f θ ( x ) mean? The model f , set up with knobs θ , applied to input x — i.e. the model's guess for x .
What is ℓ i and why is it a number, not a yes/no? The loss (wrongness) on example i ; a smooth number tells us how wrong and hence which way to improve, which yes/no cannot.
Expand ∑ i = 1 N ℓ i in words. Add up the losses of examples 1 through N into one bucket.
Why divide the total loss by N to get J ? To make it an average, so the value doesn't secretly grow just because the dataset is bigger.
What does the gradient ∇ θ J point toward, and which way do we walk? Toward steepest uphill of the loss; we step the opposite (downhill) direction.
In θ t + 1 = θ t − η g , what are η and the minus sign doing? η is the stride length (learning rate); the minus makes us step downhill, against the uphill gradient.
What is a mini-batch B and what does m ≪ N tell you? A small random handful of examples; m ≪ N says the batch is orders of magnitude smaller than the whole dataset.
What do E [ ⋅ ] and Var ( ⋅ ) measure? Expectation = long-run average of a random quantity; variance = how much it spreads around that average.
What is one epoch, and how many steps does it contain? One full pass over all N examples; it contains ⌈ N / m ⌉ batch updates.