AdaGrad divides each gradient by the root of the running sum of squares: 3/3 = 1, then 4/5 = 0.8, then 0 for a zero gradient. The second coordinate sees its first gradient at step 2, so its update is the full alpha with the sign of that gradient.
The Adam paper shows that AdaGrad is a special case of Adam: set β1=0, let β2 approach 1, and shrink the stepsize as α/t. Implement both update rules on a fixed stream of gradients so the claim can be checked step by step, including what happens when Adam's bias correction is switched off.
adagrad_steps(grads, alpha) -> np.ndarray
grads: array of shape (T, d), row t−1 is gt.
Returns the (T, d) array of AdaGrad updates (the amounts subtracted from the parameters):
ut=α∑s=1tgs2gt.
Returns the (T, d) array of updates of Adam with β1=0 (so m^t=gt), stepsize αt=α/t and no ϵ:
vt=β2vt−1+(1−β2)gt2,v0=0,ut=tαv^tgt,
with v^t=vt/(1−β2t) when bias_correction is true and v^t=vt otherwise.
Notes
All operations are element-wise. Where the denominator is 0 (a coordinate that has only seen zero gradients), the update is 0.