Intuition The ONE core idea
Training a model means rolling a ball downhill on a landscape whose height is "how wrong the model is." Every symbol in this topic is just a tool for answering one question: which way is downhill, and how sure are we? — and the three methods (Batch, Mini-batch, SGD) differ only in how much data we sample to answer that question .
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.
Definition What is a training example?
A training example is a pair: an input x i (what the model sees) and a target y i (the right answer we wish it would produce).
x i — plain words: the i -th input. In aerospace, maybe the wing shape parameters fed to a drag model.
y i — plain words: the i -th correct answer (the measured drag).
N — plain words: how many examples we have in total. The little subscript i just counts them: i = 1 , 2 , 3 , … , N .
The subscript i is a name tag , not a multiplication. x 5 means "the 5th input", the same way "chair #5" points at one chair in a row.
Look at the figure: each dot is one ( x i , y i ) pair plotted on a grid. N is simply the number of dots. That whole cloud of dots is all the data — the thing Batch GD looks at in one go.
Intuition Why the topic needs this
The three methods are literally defined by how many of these dots you look at before moving. So the very first symbol you must own is N (the total count) and the idea of a single indexed example ( x i , y i ) .
f and parameters θ
f is the model : a machine that takes an input x and guesses an output. Written f ( x ) .
θ (Greek letter "theta") is the set of adjustable knobs inside the model — the numbers we are allowed to change to make guesses better.
Writing f θ ( x ) means "the model f , using the current knob settings θ , applied to input x ."
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.
Worked example The simplest possible model
The parent uses y = θ x . Here θ is a single knob (one number). If θ = 2 , the model predicts 2 x . If the true relationship is y = 2 x , then θ = 2 is the perfect dial setting, written θ ∗ = 2 (the star means "the ideal value").
Common mistake Common confusion
"θ is one number." ::: Not always! In real networks θ is thousands or millions of numbers stacked together (a vector ). We write it with one letter for convenience, but picture a long list of dials.
Definition Loss of one example,
L i
L i is a number that says how wrong the model was on example i : big when the guess is far from y i , zero when perfect.
The parent uses squared loss : L i = 2 1 ( f θ ( x i ) − y i ) 2 .
Why squared ? Two reasons, both visual:
Squaring makes every error positive (a miss above and a miss below both count as "bad").
The square is a smooth U-shaped bowl — and a bowl has a clear bottom you can roll down to. See the figure.
Read ∑ i = 1 N out loud as: "add up, for i going from 1 to N ." The N 1 in front turns that big sum into an average . So J is "on average, how wrong is the model right now?"
Intuition Why the topic needs
J
J is the landscape. Its height at each dial setting θ tells you how bad that setting is. Our whole job is to find the θ where J is lowest — the bottom of the bowl.
Now the key question: standing at some θ , which way is downhill on the J landscape? The tool that answers "which way and how steeply does a curve go" is the derivative .
Definition Derivative — "steepness of a curve at a point"
The derivative of J with respect to θ , written d θ dJ , is the slope of the curve at your current spot: how much J changes for a tiny nudge in θ .
Slope positive → curve rising to the right → downhill is to the left .
Slope negative → curve falling to the right → downhill is to the right .
Slope zero → you are on flat ground: bottom of a bowl, top of a hill, or a saddle.
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.
Definition The chain rule (used in every gradient)
When you differentiate a nested expression like 2 1 ( θ x − y ) 2 , you peel the layers from outside in. Call the inside u = θ x − y , so the expression is 2 1 u 2 .
Differentiate the outer 2 1 u 2 with respect to u : the power rule brings the 2 down as a multiplier, giving 2 ⋅ 2 1 ⋅ u = u . Here is where the half goes: the 2 1 was placed on purpose so that when the power's 2 comes down, 2 × 2 1 = 1 and they cancel exactly — leaving a clean u with no stray factor.
Then multiply by the derivative of the inside u = θ x − y with respect to θ , which is x .
Result: u ⋅ x = ( θ x − y ) x .
That single result is what the parent's Worked Example 1 uses — now you know exactly where the ⋅ x comes from, and why no 2 1 survives.
Definition From one derivative to the gradient
∇ θ J
When θ is a list of knobs ( θ 1 , θ 2 , … ) , you can only wiggle one knob at a time and ask "how does J change?" That single-knob slope is a partial derivative , written ∂ θ 1 ∂ J (the curly ∂ says "hold the other knobs still").
Do this for every knob and stack the answers into a column — that stacked list is the gradient:
∇ θ J = ∂ θ 1 ∂ J ∂ θ 2 ∂ J ⋮
Plain words: the gradient is an arrow built by measuring steepness in each knob's direction separately, then gluing those numbers together. The arrow points in the steepest-uphill direction, and its length says how steep.
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 ∇ θ J — the true steepest-uphill direction. To go downhill , we go opposite the arrow: − ∇ θ J .
Mnemonic Nabla = "the uphill arrow"
∇ J points up the hill. Minus flips it. That minus sign in the update rule (next section) is the whole reason we descend .
η
η (Greek "eta") is a small positive number — the step size . It controls how far you move each time you take a downhill step.
η too small → tiny baby steps, painfully slow.
η too big → you overshoot the valley and bounce up the far wall.
Δ θ — the change in the knob
Δ (Greek "delta") means "change in." Δ θ is "how much we shift the dial this step." Using the true gradient we would set Δ θ = − η ∇ θ J : step size × downhill direction.
Putting it together, the ideal update is:
θ ← θ − η ∇ θ J
The arrow ← means "replace with" — assign the new value to θ . It is not an equation; it is an action.
Intuition But we rarely have the true gradient — enter the estimate
Computing ∇ θ J exactly means summing over all N examples, which is expensive. So in practice we swap the true gradient for a cheaper estimate (built from a subset of the data), a quantity we will call g ^ and define carefully in the next section. The parent's boxed rule is exactly this swap:
θ ← θ − η g ^ ( g ^ ≈ ∇ θ J )
Batch, Mini-batch and SGD are simply three ways to build g ^ — same rule, different estimate.
g ^
A hat over a letter means "our estimate of the thing." g ^ is our guess of the true gradient ∇ θ J , computed from however many examples we chose to look at.
Batch: guess uses all N → guess equals the truth.
SGD: guess uses 1 → noisy guess.
E — "the long-run average"
E [ ⋅ ] reads "the average value you'd get if you repeated the random pick many, many times." The subscript, as in E k , says which random thing we're averaging over (here, the random example index k ).
Saying E k [ ∇ L k ] = ∇ J means: pick one example at random, and on average its gradient equals the true gradient. That is what unbiased means — right on average.
Var — "how much it jitters"
Var [ g ^ ] measures how much your guess bounces around from pick to pick. Big variance = noisy, jittery path down the hill. Small variance = smooth path.
Key fact the parent uses: averaging B independent examples cuts variance by B :
Var [ g ^ ] = B σ 2
where σ 2 is the jitter of a single example. More examples in the average → steadier arrow.
Look at the figure: three descent paths on the same bowl — the wobbly one (SGD, B = 1 ), the medium one (mini-batch), the smooth one (Batch). Same destination, different amounts of jitter, exactly as σ 2 / B predicts.
B and epoch
B = how many examples go into one gradient estimate before you step.
An epoch = one full pass through all N examples. If you use B at a time, you take N / B steps to see everything once.
That N / B is the entire content of the parent's Worked Example 3: 1000/100 = 10 updates per epoch.
Read the chain of dependencies from top to bottom — each box is a foundation from this page, and you cannot skip a link. Data ( x i , y i , N ) define what the model f θ is judged against; that judgement is the loss L i , averaged into the landscape J ; the slope of J (derivative → gradient ∇ θ J ) tells us which way is downhill; the learning rate η sizes the step; and finally the estimate g ^ (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
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
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 ∇ θ J for real networks).
Self-test: can you say each answer before revealing it?
What does the subscript i in x i mean? A name tag / counter picking out the i -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 ∑ i = 1 N tell you to do? Add up the term for i = 1 through N .
What does the derivative dJ / d θ tell you physically? The slope of the loss curve at your current spot — which way and how steeply it tilts.
Why does no 2 1 survive in the gradient of the squared loss? The power rule brings down a 2 which cancels the 2 1 (2 × 2 1 = 1 ); the 2 1 was chosen precisely for this.
What is a partial derivative ∂ J / ∂ θ 1 ? The slope of J when you wiggle only knob θ 1 and hold all other knobs still.
How is the gradient ∇ θ J 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 ∇ θ J point? Uphill (steepest increase); we move opposite it, − ∇ θ J , to go downhill.
What role does η play? The step size (learning rate) — how far you move each update.
Why does the real update use g ^ instead of ∇ θ J ? The true gradient is expensive (all N terms); g ^ is a cheaper estimate from a subset, and the three methods differ only in how g ^ is built.
What does the arrow in θ ← θ − η g ^ mean? "Replace θ with the new value" — an assignment/action, not an equality.
What does the hat in g ^ signify? It is an estimate of the true gradient, built from a subset of the data.
What does E k [ ∇ L k ] = ∇ J 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 B ? It shrinks as σ 2 / B : larger batch, less jitter.
How many updates per epoch with N samples and batch size B ? N / B .