diff options
Diffstat (limited to 'tensorflow/python/kernel_tests/reduction_ops_test.py')
-rw-r--r-- | tensorflow/python/kernel_tests/reduction_ops_test.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tensorflow/python/kernel_tests/reduction_ops_test.py b/tensorflow/python/kernel_tests/reduction_ops_test.py index a8023f2e73..7e250e1004 100644 --- a/tensorflow/python/kernel_tests/reduction_ops_test.py +++ b/tensorflow/python/kernel_tests/reduction_ops_test.py @@ -260,6 +260,9 @@ class SumReductionTest(tf.test.TestCase): def testGradient4(self): self._compareGradient([2, 3, 4, 2], [], None) + def testGradient5(self): + self._compareGradient([2, 3, 4, 2], [3, 4, 2], 0) + def testHighRank(self): # Do a bunch of random high dimensional reductions np.random.seed(42) @@ -380,6 +383,15 @@ class MeanReductionTest(tf.test.TestCase): t, s, su, [2, 3, 4, 2], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-3, atol=1e-3) + su = tf.reduce_mean(t, 0) + jacob_t, jacob_n = tf.test.compute_gradient(t, + s, + su, + [3, 4, 2], + x_init_value=x, + delta=1) + self.assertAllClose(jacob_t, jacob_n, rtol=1e-3, atol=1e-3) + def testEmptyGradients(self): with self.test_session(): x = tf.zeros([0, 3]) @@ -459,6 +471,15 @@ class ProdReductionTest(tf.test.TestCase): t, x.shape, su, [1], x_init_value=x, delta=1) self.assertAllClose(jacob_t, jacob_n, rtol=1e-3, atol=1e-3) + su = tf.reduce_prod(t, 0) + jacob_t, jacob_n = tf.test.compute_gradient(t, + x.shape, + su, + [3, 4, 2], + x_init_value=x, + delta=1) + self.assertAllClose(jacob_t, jacob_n, rtol=1e-3, atol=1e-3) + def testGradientWithZeros(self): s = [2, 3, 4, 2] x = np.arange(1.0, 49.0).reshape(s).astype(np.float32) / 20. |