@test_util.run_deprecated_v1
def testSharing(self):
    for dtype in [dtypes.half, dtypes.float32, dtypes.float64]:
        with self.cached_session():
            (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 = variables.Variable(var0_np)
            var1 = variables.Variable(var1_np)
            grads0 = constant_op.constant(grads0_np)
            grads1 = constant_op.constant(grads1_np)
            opt = adam.Adam()
            update1 = opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
            update2 = opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
            variables.global_variables_initializer().run()
            (beta_1_power, beta_2_power) = get_beta_accumulators(opt, dtype)
            self.assertAllClose([1.0, 2.0], self.evaluate(var0))
            self.assertAllClose([3.0, 4.0], self.evaluate(var1))
            for t in range(3):
                self.assertAllCloseAccordingToType((0.9 ** (t + 1)), self.evaluate(beta_1_power))
                self.assertAllCloseAccordingToType((0.999 ** (t + 1)), self.evaluate(beta_2_power))
                if ((t % 2) == 0):
                    update1.run()
                else:
                    update2.run()
                (var0_np, m0, v0) = adam_update_numpy(var0_np, grads0_np, t, m0, v0)
                (var1_np, m1, v1) = adam_update_numpy(var1_np, grads1_np, t, m1, v1)
                self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0))
                self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1))
@test_util.run_deprecated_v1
def testSharing(self):
    for dtype in [dtypes.half, dtypes.float32, dtypes.float64]:
        with self.cached_session():
            (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 = variables.Variable(var0_np)
            var1 = variables.Variable(var1_np)
            grads0 = constant_op.constant(grads0_np)
            grads1 = constant_op.constant(grads1_np)
            opt = adam.Adam()
            update1 = opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
            update2 = opt.apply_gradients(zip([grads0, grads1], [var0, var1]))
            variables.global_variables_initializer().run()
            (beta_1_power, beta_2_power) = get_beta_accumulators(opt, dtype)
            self.assertAllClose([1.0, 2.0], self.evaluate(var0))
            self.assertAllClose([3.0, 4.0], self.evaluate(var1))
            for t in range(3):
                self.assertAllCloseAccordingToType((0.9 ** (t + 1)), self.evaluate(beta_1_power))
                self.assertAllCloseAccordingToType((0.999 ** (t + 1)), self.evaluate(beta_2_power))
                if ((t % 2) == 0):
                    update1.run()
                else:
                    update2.run()
                (var0_np, m0, v0) = adam_update_numpy(var0_np, grads0_np, t, m0, v0)
                (var1_np, m1, v1) = adam_update_numpy(var1_np, grads1_np, t, m1, v1)
                self.assertAllCloseAccordingToType(var0_np, self.evaluate(var0))
                self.assertAllCloseAccordingToType(var1_np, self.evaluate(var1))