Skip to content

8.2 Series convergence, the EMA as a geometric series, and bias correction

The loss a training loop prints jumps around from batch to batch, and what you care about is its trend. The standard tool for extracting that trend is an exponential moving average, and the first thing it does is lie: started from zero, it reports a loss of 0.55 when every batch says 5.5, and climbs toward the truth over hundreds of steps. Adam, the optimizer every model in AI Engineering trains with, keeps two such averages per parameter and would take wildly wrong first steps without the correction this section derives.

Concepts from other sections (8)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

Both the lie and the fix are a fact about one infinite sum, the geometric series. This section defines what it means for a series to converge, sums the geometric series exactly, and builds the EMA and its bias correction on top of the geometric and geometric_sum helpers from Sequences, geometric series, and frequency ladders. The notion of a limit comes from Derivatives and finite differences.

The finished code is course/solutions/python/tinyllm/num/ema.py, which provides ema_weights and the class EMA (with update, value, t, and value_debiased); its interface is fixed by the contract course/contracts/py/tinyllm/num/ema.pyi.

Learning objectives

  • Define convergence of a series through its partial sums and show why the harmonic series diverges.
  • Derive the partial sum 1−rt1−r\frac{1 - r^t}{1 - r} of a geometric series and its limit for ∣r∣<1|r| < 1.
  • Unroll the EMA recursion into a weighted sum with geometric weights, and compute its effective window and half-life.
  • Derive the bias correction m^t=mt/(1−βt)\hat m_t = m_t / (1 - \beta^t) and explain why it requires the zero start.
  • Implement an EMA class that rejects non-finite input without corrupting its state and never leaks internal arrays.

The symbols used throughout are collected here first:

SymbolMeaningType / shape
a0,a1,a2,…a_0, a_1, a_2, \ldotsa sequence of numbers
St=∑j=0t−1ajS_t = \sum_{j=0}^{t-1} a_jthe tt-th partial sumfloat
rrthe ratio of a geometric sequence, aj=arja_j = a r^jfloat
xtx_tthe input at step t=1,2,…t = 1, 2, \ldotsfloat or array
β\betathe decay, 0≤β<10 \le \beta < 1float
mtm_tthe EMA after tt updates, m0=0m_0 = 0float or array
wi(t)w_i^{(t)}the weight of xix_i in mtm_tfloat
m^t\hat m_tthe bias-corrected average mt/(1−βt)m_t / (1 - \beta^t)float or array

A series ∑j≥0aj\sum_{j \ge 0} a_j is the sequence of its partial sums St=a0+⋯+at−1S_t = a_0 + \cdots + a_{t-1}. It converges to SS when the partial sums settle on SS in the sense of a limit: for every tolerance there is a tt beyond which every StS_t is within it. Otherwise it diverges.

Small terms are necessary but not enough. The harmonic series 1+12+13+14+⋯1 + \frac12 + \frac13 + \frac14 + \cdots diverges, because the terms from 12k+1\frac{1}{2^k + 1} to 12k+1\frac{1}{2^{k+1}} are 2k2^k numbers each at least 12k+1\frac{1}{2^{k+1}}, adding to at least 12\frac12 for every kk, so the sum passes any bound.

A useful sufficient condition is the ratio test: if ∣aj+1/aj∣|a_{j+1}/a_j| eventually stays below some q<1q < 1, the series converges, because from there on its terms are smaller than those of a geometric series with ratio qq. The previous section, Taylor series, remainder bounds, and range reduction, used exactly this argument to bound the tail of the erf series. Everything therefore rests on the geometric series, which is where we turn next.

For aj=arja_j = a r^j, multiply the partial sum by rr and subtract. Everything but the first and last terms cancels:

St−rSt=a−art⟹St=a 1−rt1−r(r≠1),St=at(r=1).S_t - r S_t = a - a r^t \quad\Longrightarrow\quad S_t = a\,\frac{1 - r^t}{1 - r} \quad (r \neq 1), \qquad S_t = a t \quad (r = 1) .

If ∣r∣<1|r| < 1, rt→0r^t \to 0 and the series converges to a1−r\frac{a}{1 - r}; if ∣r∣≥1|r| \ge 1 the terms do not shrink and it diverges.

There is one numerical catch. When rr is close to 1, 1−rt1 - r^t subtracts two nearly equal numbers. The geometric_sum helper evaluates it as expm1(tln⁡r)r−1\frac{\mathrm{expm1}(t \ln r)}{r - 1} to keep full precision, and the code here calls it rather than re-deriving it.

The update mt=βmt−1+(1−β)xtm_t = \beta m_{t-1} + (1 - \beta)x_t keeps a fraction β\beta of the old average and mixes in 1−β1 - \beta of the new input. Unroll it from m0=0m_0 = 0 and the geometric series appears:

mt=(1−β)xt+β(1−β)xt−1+β2(1−β)xt−2+⋯+βt−1(1−β)x1=∑i=1t(1−β)βt−i⏟wi(t) xi.m_t = (1 - \beta)x_t + \beta(1 - \beta)x_{t-1} + \beta^2(1 - \beta)x_{t-2} + \cdots + \beta^{t-1}(1 - \beta)x_1 = \sum_{i=1}^{t} \underbrace{(1 - \beta)\beta^{t-i}}_{w_i^{(t)}}\, x_i .

The newest input has weight 1−β1 - \beta, and each step back in time multiplies the weight by β\beta: a geometric sequence. ema_weights(beta, t) returns w1(t),…,wt(t)w_1^{(t)}, \ldots, w_t^{(t)} oldest first, which is geometric(1 - beta, beta, t) reversed.

Two numbers summarize how far back the average looks. The effective window is 11−β\frac{1}{1 - \beta} (the sum of the infinite weight sequence divided by its largest weight): 10 steps for β=0.9\beta = 0.9, 1000 for β=0.999\beta = 0.999. The half-life, after which an input’s weight has halved, is ln⁡12ln⁡β\frac{\ln \frac12}{\ln \beta}: 6.6 steps for β=0.9\beta = 0.9.

Now the lie becomes visible. The weights add up to a geometric partial sum:

∑i=1twi(t)=(1−β)1−βt1−β=1−βt.\sum_{i=1}^{t} w_i^{(t)} = (1 - \beta)\frac{1 - \beta^t}{1 - \beta} = 1 - \beta^t .

An average whose weights add to less than 1 is pulled toward 0, which is where it started. If every xi=cx_i = c, then mt=c(1−βt)m_t = c(1 - \beta^t): after one step with β=0.9\beta = 0.9, only 0.1c0.1c. Dividing by the total turns the weights back into an average,

m^t=mt1−βt,\hat m_t = \frac{m_t}{1 - \beta^t} ,

and for a constant input m^t=c\hat m_t = c at every tt, exactly in real arithmetic (and to a few ε/(1−β)\varepsilon/(1 - \beta) in float64). If the inputs are random with the same mean μ\mu, the expected value of mtm_t is (1−βt)μ(1 - \beta^t)\mu, so m^t\hat m_t is an unbiased estimate of μ\mu. That is why Adam’s update has the right size from its first step.

The correction matters only early. βt\beta^t falls below 1 percent after t≈4.61−βt \approx \frac{4.6}{1 - \beta} steps, and from then on m^t≈mt\hat m_t \approx m_t.

Two consequences shape the code. First, the zero start is part of the definition: initializing mm with x1x_1 and then dividing by 1−βt1 - \beta^t corrects a bias that is not there (m^1=10 x1\hat m_1 = 10\,x_1 for β=0.9\beta = 0.9). Second, at t=0t = 0 the correction is 0/00/0: nothing has been averaged, so value_debiased raises instead of returning a number.

Take β=0.9\beta = 0.9 and inputs x1=1x_1 = 1, x2=2x_2 = 2, x3=3x_3 = 3. The recursion, the weight total, and the corrected value evolve like this:

ttmt=0.9 mt−1+0.1 xtm_t = 0.9\,m_{t-1} + 0.1\,x_t1−0.9t1 - 0.9^tm^t\hat m_t
10.9⋅0+0.1⋅1=0.10.9 \cdot 0 + 0.1 \cdot 1 = 0.10.10.1/0.1=10.1/0.1 = 1
20.9⋅0.1+0.1⋅2=0.290.9 \cdot 0.1 + 0.1 \cdot 2 = 0.290.190.29/0.19=1.52631580.29/0.19 = 1.5263158
30.9⋅0.29+0.1⋅3=0.5610.9 \cdot 0.29 + 0.1 \cdot 3 = 0.5610.2710.561/0.271=2.07011070.561/0.271 = 2.0701107

Unrolled, m3=0.081⋅1+0.09⋅2+0.1⋅3=0.081+0.18+0.3=0.561m_3 = 0.081 \cdot 1 + 0.09 \cdot 2 + 0.1 \cdot 3 = 0.081 + 0.18 + 0.3 = 0.561: the same number, with weights [0.081,0.09,0.1][0.081, 0.09, 0.1] adding to 0.271=1−0.930.271 = 1 - 0.9^3. The biased m3=0.561m_3 = 0.561 is below even the smallest input; the debiased 2.07 is a weighted average of 1, 2, 3 that leans toward the newest.

The module exposes one function and one class:

def ema_weights(beta: float, t: int) -> NDArray: ... # oldest first, sum 1 - beta**t
class EMA:
def __init__(self, beta: float) -> None: ... # 0 <= beta < 1, m_0 = 0
t: int # property: updates so far
value: float | NDArray # property: m_t (a copy)
def update(self, x: ArrayLike) -> float | NDArray: ...
def value_debiased(self) -> float | NDArray: ... # m_t / (1 - beta**t)

A number in gives a Python float out; an array in gives a new float64 array, averaged elementwise, and later updates must keep its shape. Non-finite input raises ValueError and leaves the state unchanged; value_debiased before any update raises RuntimeError.

Each design decision follows from the derivation above.

  1. The state is two numbers: mtm_t and tt. The recursion mt=βmt−1+(1−β)xtm_t = \beta m_{t-1} + (1-\beta)x_t needs only the previous average, and the correction 1−βt1 - \beta^t needs only the count. Keeping the whole history is unnecessary, since the unrolled form shows the recursion is the weighted sum.
  2. Start at m0=0m_0 = 0. The bias correction is derived for that start. Seeding with x1x_1 and also dividing by 1−βt1 - \beta^t would correct a bias that is not there.
  3. The correction total comes from geometric_sum. ∑iwi(t)=(1−β)1−βt1−β\sum_i w_i^{(t)} = (1-\beta)\frac{1-\beta^t}{1-\beta} is exactly geometric_sum(1 - beta, beta, t), which stays accurate for β\beta near 1 where 1−βt1 - \beta^t cancels.
  4. t=0t = 0 has no average. The debiased value would be 0/00/0; raising is the only honest answer.
  5. Validate before mutating. A non-finite input or a shape change raises before the state changes, so one bad batch leaves the curve intact. β\beta is checked once, at construction: 0≤β<10 \le \beta < 1 (with β=1\beta = 1 the average never moves and the correction divides by 0).
  6. Never hand out internal state. Returning the internal array would let a caller’s in-place edit change the average, so every array returned is a copy, and scalars come back as Python float.
  7. The weights are the geometric sequence, reversed. geometric(1 - beta, beta, t) lists (1−β),(1−β)β,…(1-\beta), (1-\beta)\beta, \ldots, newest first; the contract lists x1x_1 (the oldest) first, so reverse it.

Validating β\beta and listing the weights

Section titled “Validating β\betaβ and listing the weights”
def _check_beta(beta: float) -> float:
b = float(beta)
# isfinite first, so nan fails; beta = 0 is allowed (the EMA is the last value)
if not (math.isfinite(b) and 0.0 <= b < 1.0):
raise ValueError(f"beta must satisfy 0 <= beta < 1, got {beta}")
return b
def ema_weights(beta: float, t: int) -> NDArray:
b = _check_beta(beta)
if t < 0:
raise ValueError(f"t must be >= 0, got {t}")
# (1 - b), (1 - b) b, (1 - b) b^2, ... is newest first; x_1 is the oldest.
return geometric(1.0 - b, b, int(t))[::-1].copy()

The .copy() turns the reversed view into a fresh, contiguous array. For β=0.9\beta = 0.9, t=3t = 3: geometric(0.1, 0.9, 3) is [0.1,0.09,0.081][0.1, 0.09, 0.081], reversed to [0.081,0.09,0.1][0.081, 0.09, 0.1], the weights of the hand example.

class EMA:
def __init__(self, beta: float) -> None:
self.beta = _check_beta(beta)
self._t = 0
self._m: float | NDArray = 0.0 # m_0 = 0, the start the correction assumes
self._shape: tuple | None = None # fixed by the first update
@property
def t(self) -> int:
return self._t
@property
def value(self) -> float | NDArray:
m = self._m
return m.copy() if isinstance(m, np.ndarray) else float(m)
def update(self, x: ArrayLike) -> float | NDArray:
a = np.asarray(x, dtype=np.float64)
if not np.isfinite(a).all(): # checked before any state changes
raise ValueError(
"x must be finite: one nan or inf would poison every later average"
)
if self._shape is not None and a.shape != self._shape:
raise ValueError(
f"x has shape {a.shape}, earlier updates had {self._shape}"
)
# Start from m_0 = 0, never from x_1: the bias correction below
# assumes the zero start, and the two together would double-correct.
m = self.beta * self._m + (1.0 - self.beta) * (a if a.ndim else float(a))
self._shape = a.shape
self._m = m
self._t += 1
return self.value # a copy, or a Python float
def value_debiased(self) -> float | NDArray:
if self._t == 0:
raise RuntimeError(
"value_debiased before any update: the average of nothing is 0 / 0"
)
# The weights of m_t add up to (1 - b)(1 + b + ... + b^(t-1)) = 1 - b^t.
# geometric_sum (M00.3) gets that total right even for b near 1, where
# 1 - b**t subtracts two nearly equal numbers.
out = self._m / geometric_sum(1.0 - self.beta, self.beta, self._t)
return out.copy() if isinstance(out, np.ndarray) else float(out)

The expression (a if a.ndim else float(a)) keeps scalars as Python floats, so a scalar EMA stays a float all the way through, while an array input makes m a new float64 array (the expression allocates a new array; nothing is updated in place). Run the hand example through it: after update(1), update(2), update(3) with β=0.9\beta = 0.9, value is 0.5610.561, t is 3, and value_debiased() divides by geometric_sum(0.1, 0.9, 3) =0.271= 0.271, giving 2.07011072.0701107. With β=0\beta = 0, geometric_sum(1.0, 0.0, t) is 1 and mt=xtm_t = x_t, so both values are the latest input.

The full solution is ema.py.

update is O(1)O(1) per scalar (O(d)O(d) for an array of dd elements) and the state is O(1)O(1) (or O(d)O(d)), however many steps have run. value_debiased adds one geometric_sum, which is O(1)O(1). Recomputing ∑iwixi\sum_i w_i x_i from a stored history would cost O(t)O(t) time and memory per step.

The recursion is preferred over the explicit sum for the same reason. Both give the same number, as the hand example shows, but the recursion needs no history and rounds only a couple of times per step, so its rounding error stays at a few hundred ulps after many steps.

Computing the total beats tracking it. You could keep a running βt\beta^t by multiplying by β\beta each step and then form 1−βt1 - \beta^t, but that rounds once per step and then cancels for β\beta near 1. geometric_sum evaluates the total from tt and β\beta directly, accurate at any tt.

Raising beats skipping bad inputs. Silently dropping a NaN would hide a real failure upstream (a diverged batch); raising with the state unchanged lets the caller decide, and the curve stays valid either way.

One tradeoff is accepted: the EMA keeps one decay for its whole life. Schedules that change β\beta over time (annealing) need a new object or a different correction, because 1−βt1 - \beta^t assumes a constant β\beta.

A correct implementation must pass the following checks, each tied to something that depends on it:

CaseKind of checkChecksWhy it matters downstream
the hand-worked EMAunitthe hand example’s mtm_t and m^t\hat m_t, the counter, Python floatseveryone agrees on the recursion and the correction
the hand-worked weightsunit[0.081,0.09,0.1][0.081, 0.09, 0.1], total 0.271the unrolled form
weights total 1−βt1 - \beta^tpropertytotals 1−βt1 - \beta^t and ratio β\beta for five β\beta and five ttthe geometric partial sum
recursion equals weighted sumdifferentialthe recursion equals the dot product with ema_weights on 200 seeded inputstwo definitions, one number
a debiased constant is exactpropertym^t=c\hat m_t = c for β\beta up to 0.9999, tt up to 3000the central property of the EMA
exact rational arithmeticgoldenthe float64 mtm_t and m^t\hat m_t against the same recursion in exact rational arithmetic (fractions.Fraction), rounded once, after 200 seeded stepsrounding in the recursion stays at a few hundred ulps
the bias fadespropertym50=10(1−0.950)m_{50} = 10(1 - 0.9^{50})how long the bias lasts
β=0\beta = 0boundaryβ=0\beta = 0 returns the latest inputannealed schedules
arrays averaged elementwisedifferentialan array EMA equals one scalar EMA per element; returned arrays are copies; shape changes raiseEMA weights over whole tensors in the TinyStories capstone
non-finite inputboundaryNaN and inf raise, state unchangedone bad batch must not poison the curve
debiasing before any updateboundaryt=0t = 0 raises RuntimeError0/0 is not a number
bad β\betaboundaryβ<0\beta < 0, β≥1\beta \ge 1, NaN raiseβ=1\beta = 1 never moves

The common mistakes each leave a recognizable fingerprint.

Warning: Swapping β\beta and 1−β1 - \beta in the update makes the average follow the newest input with weight 0.9 and forget at once. The update must read self.beta * self._m + (1.0 - self.beta) * x.

Starting from m0=x1m_0 = x_1 and still dividing by 1−βt1 - \beta^t gives m^1=10 x1\hat m_1 = 10\,x_1 for β=0.9\beta = 0.9; _m must start at 0.0. An off-by-one power, 1−βt+11 - \beta^{t+1} or 1−βt−11 - \beta^{t-1}, gives m^1=0.526\hat m_1 = 0.526 for x1=1x_1 = 1, or a division by zero at t=1t = 1; the total is geometric_sum(..., self._t) with _t incremented once per update. Accepting NaN or inf makes every later average NaN; np.isfinite(a).all() is checked before any state changes. Forgetting the correction entirely reports the hand example’s 0.1 as the average of 1; value_debiased divides by the weight total.

The remaining mistakes are subtler. Listing the weights newest first produces a weighted sum with the wrong inputs emphasized; ema_weights reverses geometric(...). Rejecting β=0\beta = 0 refuses a valid, if trivial, average; _check_beta accepts 0.0 <= b. Returning the internal array from update lets a caller’s in-place edit change the average; update returns self.value, a copy. Having no check at t=0t = 0 yields a ZeroDivisionError instead of a clear error; value_debiased raises RuntimeError when _t == 0.

The EMA shows up as soon as you train anything. In AI Engineering, Training loop and the autograd bigram passes ema=EMA(beta) to train_step, which feeds each step’s loss to update and reports value_debiased() as loss_ema, the smoothed loss curve. The TinyStories capstone keeps an EMA of the model weights and evaluates it alongside the raw weights. And in Adam and AdamW: bias correction and decoupled weight decay, Adam’s first and second moments are EMAs of the gradient and its square, divided by 1−β1t1 - \beta_1^t and 1−β2t1 - \beta_2^t: exactly this correction, applied twice.

  • OpenStax, Calculus Volume 2 (free), sections 5.2 and 5.3: infinite series, the geometric series, and divergence.
  • Kingma and Ba, “Adam” (2015), section 3: initialization bias correction. Adam and AdamW in torch/optim/adam.py apply the same correction to two moments, often folded into the step size α1−β2t/(1−β1t)\alpha \sqrt{1 - \beta_2^t}/(1 - \beta_1^t).
  • PyTorch torch.optim.swa_utils.AveragedModel with get_ema_multi_avg_fn (torch/optim/swa_utils.py): an EMA of every parameter tensor and buffer, updated in place on the device.
  • TensorBoard’s smoothing slider (tensorboard/plugins/scalar, the smoothing weight): a debiased EMA of the plotted scalar, exactly the one built here.
  • numpy.expm1 and numpy.log1p, the functions that make 1−βt1 - \beta^t accurate for β=0.9999\beta = 0.9999; see Sequences, geometric series, and frequency ladders.
  • Series: the sequence of partial sums St=a0+⋯+at−1S_t = a_0 + \cdots + a_{t-1} of a sequence.
  • Convergence: the partial sums settle on a finite limit; otherwise the series diverges.
  • Ratio test: if successive term ratios eventually stay below some q<1q < 1, the series converges.
  • Geometric series: ∑arj\sum a r^j, with partial sum a1−rt1−ra\frac{1 - r^t}{1 - r} and limit a1−r\frac{a}{1-r} for ∣r∣<1|r| < 1.
  • Exponential moving average (EMA): the recursion mt=βmt−1+(1−β)xtm_t = \beta m_{t-1} + (1 - \beta)x_t, a weighted sum with geometric weights.
  • Effective window: 11−β\frac{1}{1 - \beta}, roughly how many recent steps the EMA reflects.
  • Bias correction: dividing mtm_t by its weight total 1−βt1 - \beta^t so the zero start no longer pulls the average toward 0.
  • A series converges when its partial sums settle on a number; the geometric series ∑j≥0rj\sum_{j \ge 0} r^j converges to 11−r\frac{1}{1 - r} exactly when ∣r∣<1|r| < 1, and its partial sum is 1−rt1−r\frac{1 - r^t}{1 - r}.
  • The EMA mt=βmt−1+(1−β)xtm_t = \beta m_{t-1} + (1 - \beta) x_t from m0=0m_0 = 0 is a weighted sum of all inputs with geometric weights (1−β)βt−i(1 - \beta)\beta^{t-i}.
  • Those weights add up to 1−βt1 - \beta^t, not 1, so early values are biased toward 0; dividing by 1−βt1 - \beta^t fixes it, and the debiased average of a constant is that constant at every step.
  • The bias fades on its own as βt→0\beta^t \to 0, after roughly 11−β\frac{1}{1 - \beta} steps; with β=0.999\beta = 0.999 that is a thousand steps of a misleading curve.
  • One NaN in the input poisons every later average, so update rejects non-finite values and keeps its state.
  1. Why must the EMA start at m0=0m_0 = 0 rather than at the first input?

    Answer

    The correction m^t=mt/(1−βt)\hat m_t = m_t / (1 - \beta^t) is derived from the unrolled sum starting at m0=0m_0 = 0, whose weights total 1−βt1 - \beta^t. Starting at m0=x1m_0 = x_1 already gives an unbiased average (its weights total 1), so dividing by 1−βt1 - \beta^t inflates it: with β=0.9\beta = 0.9, m^1=x1/0.1=10x1\hat m_1 = x_1 / 0.1 = 10x_1. One can use either the zero start with the correction or the x1x_1 start without it, never both.

  2. Why does value_debiased divide by geometric_sum(1 - beta, beta, t) instead of computing 1 - beta**t?

    Answer

    They are equal in exact arithmetic, but for β\beta near 1 and small tt, βt\beta^t is close to 1 and 1−βt1 - \beta^t subtracts two nearly equal numbers, keeping only part of its digits. geometric_sum evaluates the same total with expm1 and log1p, so it stays accurate at β=0.9999\beta = 0.9999; that is what keeps the debiased average of a constant equal to the constant.

  3. What happens to the EMA if update accepts a single NaN, and why does the solution check before changing state?

    Answer

    mt=βmt−1+(1−β) nanm_t = \beta m_{t-1} + (1-\beta)\,\text{nan} is NaN, and every later mm is $\beta \cdot \text{nan} + \ldots = $ NaN: the whole curve is lost from that step on, since nothing ever removes the NaN. Checking first and raising before assigning _m, _shape, or _t means a rejected input leaves the EMA exactly as it was, so the caller can skip the bad batch and continue.

  4. Why does update return self.value (a copy) rather than self._m?

    Answer

    For array inputs self._m is a numpy array; returning it would hand the caller a reference to the internal state, and an in-place operation on the result (r *= 2, r[0] = 0) would silently change the average. value returns a copy, so the EMA can only be changed through update.

  5. With β=0.999\beta = 0.999, roughly how long is the uncorrected curve misleading, and how does that follow from the geometric series?

    Answer

    The uncorrected mtm_t of a constant cc is c(1−βt)c(1 - \beta^t). βt=etln⁡β≈e−t(1−β)\beta^t = e^{t \ln \beta} \approx e^{-t(1-\beta)}, which falls to 1 percent at t≈4.6/(1−β)=4600t \approx 4.6/(1-\beta) = 4600 steps, and to about 1/e1/e after 1/(1−β)=10001/(1-\beta) = 1000 steps, the effective window. For the first thousand or so steps the raw curve sits visibly below the true loss, which is why the training loop reports the debiased value.