Md. Asif Uddin
    I.7.X02

    What bias correction is correcting, and for how long

    gradient▲▲△

    Feed Adam a constant gradient g=0.1g = 0.1 and record mm, vv 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 1.0000001.000000 at every step from the first — because m^=g\hat{m} = g and v^=g2\hat{v} = g^2 exactly, so the ratio is g/∣g∣=1g/|g| = 1. 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.

    ttmm rawvv rawstep rawstep corrected
    10.010000000.010000000.00001000000.00001000003.1622683.1622681.0000001.000000
    20.019000000.019000000.00001999000.00001999004.2495824.2495821.0000001.000000
    50.040951000.040951000.00004990010.00004990015.7971325.7971321.0000001.000000
    100.065132160.065132160.00009955120.00009955126.5278746.5278741.0000001.000000

    The direction is the part worth getting right. The uncorrected step is 3.1623×3.1623\times 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 mm is (1−β1)g=0.1g(1-\beta_1)g = 0.1g, a tenth of its target, while vv is (1−β2)g2=0.001g2(1-\beta_2)g^2 = 0.001g^2, a thousandth of its target. The step divides by v\sqrt{v}, and 0.001=0.0316\sqrt{0.001} = 0.0316, so the denominator is shrunk 31.6-fold while the numerator is shrunk 10-fold. Net: 31.6/10=3.1631.6/10 = 3.16 times too large.

    How long it matters. The correction factors are 1−βt1 - \beta^t:

    tt1−β1t1 - \beta_1^t1−β2t1 - \beta_2^t
    10.100000000.100000000.001000000.00100000
    100.651321560.651321560.009955120.00995512
    1000.999973440.999973440.095207850.09520785
    10001.000000001.000000000.632304580.63230458
    50001.000000001.000000000.993278890.99327889

    The first moment’s correction is finished by step 100. The second’s is still correcting by a factor of 1.61.6 at step 1000 and only settles around 5000 — because β2=0.999\beta_2 = 0.999 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.

    Draws on