5.6.10 · D1Machine Learning (Aerospace Applications)

Foundations — Batch, mini-batch, stochastic gradient descent

2,563 words12 min readBack to topic

Before you can read the parent note comfortably, you need to earn every symbol it throws at you. We build them one at a time, each resting on the one before. Nothing here assumes you have seen calculus or statistics — we start from a picture.


1. The training data: , ,

The subscript is a name tag, not a multiplication. means "the 5th input", the same way "chair #5" points at one chair in a row.

Figure — Batch, mini-batch, stochastic gradient descent

Look at the figure: each dot is one pair plotted on a grid. is simply the number of dots. That whole cloud of dots is all the data — the thing Batch GD looks at in one go.


2. The model and its knobs: and

Think of as the dial on a radio. Turning it changes what you hear; here, turning changes what the model predicts. Learning = finding the right dial position.


3. Measuring wrongness: the loss and

Why squared? Two reasons, both visual:

  1. Squaring makes every error positive (a miss above and a miss below both count as "bad").
  2. The square is a smooth U-shaped bowl — and a bowl has a clear bottom you can roll down to. See the figure.
Figure — Batch, mini-batch, stochastic gradient descent

Read out loud as: "add up, for going from 1 to ." The in front turns that big sum into an average. So is "on average, how wrong is the model right now?"


4. The slope: gradient and the derivative

Now the key question: standing at some , which way is downhill on the landscape? The tool that answers "which way and how steeply does a curve go" is the derivative.

Figure — Batch, mini-batch, stochastic gradient descent

Look at the tangent lines in the figure: the derivative is the tilt of the line that just kisses the curve. Steeper tilt = bigger number.

That single result is what the parent's Worked Example 1 uses — now you know exactly where the comes from, and why no survives.

Figure — Batch, mini-batch, stochastic gradient descent

Look at the figure: on a two-knob bowl, the two partial slopes (one per axis) are the two components; join them tip-to-tail and the diagonal arrow is — the true steepest-uphill direction. To go downhill, we go opposite the arrow: .


5. The step: learning rate and the update arrow

Putting it together, the ideal update is: The arrow means "replace with" — assign the new value to . It is not an equation; it is an action.


6. Estimates and averages: , , and

Figure — Batch, mini-batch, stochastic gradient descent

Look at the figure: three descent paths on the same bowl — the wobbly one (SGD, ), the medium one (mini-batch), the smooth one (Batch). Same destination, different amounts of jitter, exactly as predicts.


7. Bookkeeping words: epoch, batch size

That is the entire content of the parent's Worked Example 3: updates per epoch.


How these foundations feed the topic

Read the chain of dependencies from top to bottom — each box is a foundation from this page, and you cannot skip a link. Data define what the model is judged against; that judgement is the loss , averaged into the landscape ; the slope of (derivative → gradient ) tells us which way is downhill; the learning rate sizes the step; and finally the estimate (with its expectation and variance) is what turns the ideal step into the three real algorithms.

Training data x_i y_i and count N

Model f with knobs theta

Loss L_i one examples wrongness

Total loss J the landscape

Derivative and gradient nabla J the slope

Learning rate eta and step delta theta

Update rule theta minus eta g-hat

Estimate g-hat expectation and variance

Batch Mini-batch and SGD

Use the map to check your reading order: if any box above still feels fuzzy, that is exactly where to re-read before moving to the three descent methods. For where these ideas go next, see Gradient Descent, Learning Rate and Schedules, Loss Functions, Momentum and Adam, Saddle Points and Non-Convex Optimization, Bias-Variance Tradeoff, and Backpropagation (the machine that actually computes for real networks).


Equipment checklist

Self-test: can you say each answer before revealing it?

What does the subscript in mean?
A name tag / counter picking out the -th training example — not multiplication.
What does represent?
The adjustable knobs (parameters) of the model that we tune to reduce loss.
Why is the squared loss shaped like a bowl?
Squaring makes every error positive and smooth, giving a single clear lowest point to descend toward.
What does tell you to do?
Add up the term for = 1 through .
What does the derivative tell you physically?
The slope of the loss curve at your current spot — which way and how steeply it tilts.
Why does no survive in the gradient of the squared loss?
The power rule brings down a which cancels the (); the was chosen precisely for this.
What is a partial derivative ?
The slope of when you wiggle only knob and hold all other knobs still.
How is the gradient built from partial derivatives?
By stacking the partial derivative for each knob into one column — that stack is the arrow.
Which direction does the gradient point?
Uphill (steepest increase); we move opposite it, , to go downhill.
What role does play?
The step size (learning rate) — how far you move each update.
Why does the real update use instead of ?
The true gradient is expensive (all terms); is a cheaper estimate from a subset, and the three methods differ only in how is built.
What does the arrow in mean?
"Replace with the new value" — an assignment/action, not an equality.
What does the hat in signify?
It is an estimate of the true gradient, built from a subset of the data.
What does mean in words?
On average, a randomly chosen example's gradient equals the true gradient — the estimate is unbiased.
How does variance of the gradient estimate depend on ?
It shrinks as : larger batch, less jitter.
How many updates per epoch with samples and batch size ?
.