diff options
Diffstat (limited to 'tensorflow/python/kernel_tests/clip_ops_test.py')
-rw-r--r-- | tensorflow/python/kernel_tests/clip_ops_test.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tensorflow/python/kernel_tests/clip_ops_test.py b/tensorflow/python/kernel_tests/clip_ops_test.py index 400d38b936..de52a70cc0 100644 --- a/tensorflow/python/kernel_tests/clip_ops_test.py +++ b/tensorflow/python/kernel_tests/clip_ops_test.py @@ -27,6 +27,7 @@ from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import clip_ops from tensorflow.python.ops import gradient_checker +from tensorflow.python.ops import gradients_impl from tensorflow.python.platform import test @@ -158,13 +159,19 @@ class ClipTest(test.TestCase): ans = clip_ops.clip_by_norm(x, clip_norm) tf_ans = ans.eval() - clip_tensor = constant_op.constant(4.0) ans = clip_ops.clip_by_norm(x, clip_norm) tf_ans_tensor = ans.eval() self.assertAllClose(np_ans, tf_ans) self.assertAllClose(np_ans, tf_ans_tensor) + def testClipByNormGradientZeros(self): + with self.test_session(use_gpu=True): + x = array_ops.zeros([3]) + b = clip_ops.clip_by_norm(x, 1.) + grad, = gradients_impl.gradients(b, x) + self.assertAllEqual(grad.eval(), [1., 1., 1.]) + def testClipByNormBadShape(self): with self.test_session(use_gpu=True): x = constant_op.constant([-3.0, 0.0, 0.0, 4.0, 0.0, 0.0], shape=[2, 3, 1]) |