@test_util.run_deprecated_v1
def testBasicWithLearningRateDecay(self):
    for (i, dtype) in enumerate([dtypes.half, dtypes.float32, dtypes.float64]):
        with self.session(graph=ops.Graph()):
            (m0, v0, m1, v1) = (0.0, 0.0, 0.0, 0.0)
            var0_np = np.array([1.0, 2.0], dtype=dtype.as_numpy_dtype)
            grads0_np = np.array([0.1, 0.1], dtype=dtype.as_numpy_dtype)
            var1_np = np.array([3.0, 4.0], dtype=dtype.as_numpy_dtype)
            grads1_np = np.array([0.01, 0.01], dtype=dtype.as_numpy_dtype)
            var0 = resource_variable_ops.ResourceVariable(var0_np, name=('var0_%d' % i))
            var1 = resource_variable_ops.ResourceVariable(var1_np, name=('var1_%d' % i))
            grads0 = constant_op.constant(grads0_np)
            grads1 = constant_op.constant(grads1_np)
            learning_rate = 0.001
            beta_1 = 0.9
            beta_2 = 0.999
            epsilon = 1e-07
            decay = 0.5
            opt = adam.Adam(learning_rate=learning_rate, beta_1=beta_1, beta_2=beta_2, epsilon=epsilon, decay=decay)
            update = opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
            self.evaluate(variables.global_variables_initializer())
            for t in range(3):
                self.evaluate(update)
                lr_np = (learning_rate / (1 + (decay * t)))
                (var0_np, m0, v0) = adam_update_numpy(var0_np, grads0_np, t, m0, v0, lr=lr_np)
                (var1_np, m1, v1) = adam_update_numpy(var1_np, grads1_np, t, m1, v1, lr=lr_np)
                self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0))
                self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1))
@test_util.run_deprecated_v1
def testBasicWithLearningRateDecay(self):
    for (i, dtype) in enumerate([dtypes.half, dtypes.float32, dtypes.float64]):
        with self.session(graph=ops.Graph()):
            (m0, v0, m1, v1) = (0.0, 0.0, 0.0, 0.0)
            var0_np = np.array([1.0, 2.0], dtype=dtype.as_numpy_dtype)
            grads0_np = np.array([0.1, 0.1], dtype=dtype.as_numpy_dtype)
            var1_np = np.array([3.0, 4.0], dtype=dtype.as_numpy_dtype)
            grads1_np = np.array([0.01, 0.01], dtype=dtype.as_numpy_dtype)
            var0 = resource_variable_ops.ResourceVariable(var0_np, name=('var0_%d' % i))
            var1 = resource_variable_ops.ResourceVariable(var1_np, name=('var1_%d' % i))
            grads0 = constant_op.constant(grads0_np)
            grads1 = constant_op.constant(grads1_np)
            learning_rate = 0.001
            beta_1 = 0.9
            beta_2 = 0.999
            epsilon = 1e-07
            decay = 0.5
            opt = adam.Adam(learning_rate=learning_rate, beta_1=beta_1, beta_2=beta_2, epsilon=epsilon, decay=decay)
            update = opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
            self.evaluate(variables.global_variables_initializer())
            for t in range(3):
                self.evaluate(update)
                lr_np = (learning_rate / (1 + (decay * t)))
                (var0_np, m0, v0) = adam_update_numpy(var0_np, grads0_np, t, m0, v0, lr=lr_np)
                (var1_np, m1, v1) = adam_update_numpy(var1_np, grads1_np, t, m1, v1, lr=lr_np)
                self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0))
                self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1))