Adam's exponentially weighted second moment can shrink fast enough to make it diverge even on a convex problem. Implement single update steps of three fixes discussed in Murphy's Probabilistic Machine Learning. All operations are elementwise on 1-D arrays; no bias correction is used. Each function returns new arrays (do not modify the inputs in place).
amsgrad_step(theta, g, m, v, v_hat, lr, beta1=0.9, beta2=0.999, eps=1e-8) returns (theta, m, v, v_hat):
yogi_step(theta, g, m, s, lr, beta1=0.9, beta2=0.999, eps=1e-3) returns (theta, m, s): same momentum , the Yogi second moment
with , and using the new .
adopt_step(theta, g, m, s, lr, beta1=0.9, beta2=0.9999, eps=1e-6) returns (theta, m, s). ADOPT normalizes the gradient by the previous second moment before the momentum update, then updates :
(ADOPT is initialized with from a first gradient and ; the tests pass that state in.)