It's possible that I just misunderstood how Adam works, but why is this happening:
x = tf.Variable([0.0, 0.0]) # variable
y = tf.constant([5.0, 1.0]) # target
cost = tf.abs(x-y)**2
As the first dimension of y is larger than the second, the gradient in the first dimension is larger than the second (as it should be) and each dimension of x approaches its target value at its own rate:
sgd = tf.train.GradientDescentOptimizer(0.001)
train = sgd.minimize(cost)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for _ in range(5):
sess.run(train)
grad,variable = sess.run(opt.compute_gradients(cost))[0]
print(grad,variable)
#[-9.98 -1.996] [0.01 0.002]
#[-9.96004 -1.992008] [0.01998 0.003996]
#[-9.94012 -1.988024] [0.02994004 0.00598801]
#[-9.920239 -1.9840479] [0.03988016 0.00797603]
#[-9.900399 -1.9800799] [0.0498004 0.00996008]
Why are the rates essentially equal if we use Adam, even though the gradients have quite different values?
adam = tf.train.AdamOptimizer(0.001)
train = adam.minimize(cost)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
for _ in range(5):
sess.run(train)
grad,variable = sess.run(opt.compute_gradients(cost))[0]
print(grad,variable)
#[-9.998 -1.998] [0.001 0.001]
#[-9.996 -1.996] [0.00199999 0.00199997]
#[-9.994 -1.9940002] [0.00299997 0.00299989]
#[-9.992001 -1.9920005] [0.00399994 0.00399976]
#[-9.99 -1.990001] [0.0049999 0.00499955]
