What bias correction is correcting, and for how long
gradient▲▲△Feed Adam a constant gradient and record , and the step, with and without the bias correction of (I.7.6), for the first ten steps. Say by what factor the uncorrected first step is wrong and in which direction, then find how long the correction still matters.
Hint
Both moments start at zero, so both are biased towards zero — but one of them is under a square root in a denominator. Work out which way that pushes the step.
Solution
The correction works exactly. With a constant gradient the corrected step is at every step from the first — because and exactly, so the ratio is . That is the property the correction is for: the step size should not depend on how long training has been running.
The uncorrected step is wrong, and grows.
| raw | raw | step raw | step corrected | |
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 5 | ||||
| 10 |
The direction is the part worth getting right. The uncorrected step is too large, not too small — which is the opposite of what the phrase “biased towards zero” suggests at first reading.
Both moments are biased towards zero, but by different amounts and in different places. After one step is , a tenth of its target, while is , a thousandth of its target. The step divides by , and , so the denominator is shrunk 31.6-fold while the numerator is shrunk 10-fold. Net: times too large.
How long it matters. The correction factors are :
| 1 | ||
| 10 | ||
| 100 | ||
| 1000 | ||
| 5000 |
The first moment’s correction is finished by step 100. The second’s is still correcting by a factor of at step 1000 and only settles around 5000 — because has a memory of a thousand steps by I.7.X03.
Why this connects to warm-up. Without the correction the opening steps would be several times too large, which is precisely the damage a warm-up exists to prevent. The correction removes the systematic part of that, and a warm-up is still used — because the variance of the early estimates is high even once their bias is gone, and an estimate built from three samples is unreliable whether or not it is unbiased. Bias correction and warm-up address different halves of the same problem, which is why doing one does not remove the need for the other.