diff options
author | 2015-11-25 08:48:47 -0800 | |
---|---|---|
committer | 2015-11-25 08:48:47 -0800 | |
commit | 854f49bd43588c062b046384f239f64a3d819702 (patch) | |
tree | c2373bf71ef65ae4c116ea703947141281c1eace /tensorflow/python/ops/gradients_test.py | |
parent | 9c3043ff3bf31a6a81810b4ce9e87ef936f1f529 (diff) |
TensorFlow: Upstream changes to git
Changes:
- Updates to docs
- Several changes for Python 3 compatibility
- Added license headers
Base CL: 108710566
Diffstat (limited to 'tensorflow/python/ops/gradients_test.py')
-rw-r--r-- | tensorflow/python/ops/gradients_test.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tensorflow/python/ops/gradients_test.py b/tensorflow/python/ops/gradients_test.py index 9a87319697..5afc8a779b 100644 --- a/tensorflow/python/ops/gradients_test.py +++ b/tensorflow/python/ops/gradients_test.py @@ -24,9 +24,9 @@ import tensorflow.python.platform import numpy as np +from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import test_util -from tensorflow.python.framework import types # pylint: disable=unused-import from tensorflow.python.ops import array_grad from tensorflow.python.ops import array_ops @@ -68,7 +68,7 @@ def _OpsBetween(graph, to_ops, from_ops): reached_ops[op._id] = True gradients._MarkReachedOps(from_ops, reached_ops) between_ops = gradients._GatherInputs(to_ops, reached_ops) - between_ops.sort(lambda x, y: y._id - x._id) + between_ops.sort(key=lambda x: -x._id) return between_ops @@ -246,13 +246,13 @@ class GradientsTest(test_util.TensorFlowTestCase): @ops.RegisterGradient("TestOp") def _TestOpGrad(op, float_grad, string_grad): """Gradient function for TestOp.""" - self.assertEquals(float_grad.dtype, types.float32) + self.assertEquals(float_grad.dtype, dtypes.float32) self.assertFalse(string_grad) return float_grad ops.RegisterShape("TestOp")(None) c = constant(1.0) - x, y = g.create_op("TestOp", [c], [types.float32, types.string]).outputs + x, y = g.create_op("TestOp", [c], [dtypes.float32, dtypes.string]).outputs z = x * 2.0 w = z * 3.0 grads = gradients.gradients(z, [c]) @@ -314,7 +314,7 @@ class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase): c = constant_op.constant(np_val) c_sparse = math_ops._as_indexed_slices(c) c_sparse = ops.IndexedSlices( - c_sparse.values, math_ops.cast(c_sparse.indices, types.int64), + c_sparse.values, math_ops.cast(c_sparse.indices, dtypes.int64), c_sparse.dense_shape) self.assertAllEqual(np_val.shape, c_sparse.dense_shape.eval()) c_dense = math_ops.mul(c_sparse, 1.0) @@ -322,16 +322,16 @@ class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase): def testWarnings(self): # Smaller than the threshold: no warning. - c_sparse = ops.IndexedSlices(array_ops.placeholder(types.float32), - array_ops.placeholder(types.int32), + c_sparse = ops.IndexedSlices(array_ops.placeholder(dtypes.float32), + array_ops.placeholder(dtypes.int32), constant([4, 4, 4, 4])) with warnings.catch_warnings(record=True) as w: math_ops.mul(c_sparse, 1.0) self.assertEqual(0, len(w)) # Greater than or equal to the threshold: warning. - c_sparse = ops.IndexedSlices(array_ops.placeholder(types.float32), - array_ops.placeholder(types.int32), + c_sparse = ops.IndexedSlices(array_ops.placeholder(dtypes.float32), + array_ops.placeholder(dtypes.int32), constant([100, 100, 100, 100])) with warnings.catch_warnings(record=True) as w: math_ops.mul(c_sparse, 1.0) @@ -341,9 +341,9 @@ class IndexedSlicesToTensorTest(test_util.TensorFlowTestCase): in str(w[0].message)) # Unknown dense shape: warning. - c_sparse = ops.IndexedSlices(array_ops.placeholder(types.float32), - array_ops.placeholder(types.int32), - array_ops.placeholder(types.int32)) + c_sparse = ops.IndexedSlices(array_ops.placeholder(dtypes.float32), + array_ops.placeholder(dtypes.int32), + array_ops.placeholder(dtypes.int32)) with warnings.catch_warnings(record=True) as w: math_ops.mul(c_sparse, 1.0) self.assertEqual(1, len(w)) |