aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/kernel_tests/unpack_op_test.py
diff options
context:
space:
mode:
authorGravatar Gunhan Gulsoy <gunan@google.com>2016-08-05 16:34:48 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-08-05 17:47:29 -0700
commite3d37a62a209e8ebade236c1f4e17ac770e88eee (patch)
treed3773cd8a01bd68d8190c0b92ca1b3c6b40759d7 /tensorflow/python/kernel_tests/unpack_op_test.py
parent382859a11fb658d3a87f80a167f1003512eb57c3 (diff)
Remove more uses of use_gpu from tensorflow tests.
Change: 129501616
Diffstat (limited to 'tensorflow/python/kernel_tests/unpack_op_test.py')
-rw-r--r--tensorflow/python/kernel_tests/unpack_op_test.py63
1 files changed, 30 insertions, 33 deletions
diff --git a/tensorflow/python/kernel_tests/unpack_op_test.py b/tensorflow/python/kernel_tests/unpack_op_test.py
index 75a0cf3c37..f4bc4955f4 100644
--- a/tensorflow/python/kernel_tests/unpack_op_test.py
+++ b/tensorflow/python/kernel_tests/unpack_op_test.py
@@ -35,43 +35,40 @@ class UnpackOpTest(tf.test.TestCase):
def testSimple(self):
np.random.seed(7)
- for use_gpu in False, True:
- with self.test_session(use_gpu=use_gpu):
- for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2):
- data = np.random.randn(*shape)
- # Convert data to a single tensorflow tensor
- x = tf.constant(data)
- # Unpack into a list of tensors
- cs = tf.unpack(x, num=shape[0])
- self.assertEqual(type(cs), list)
- self.assertEqual(len(cs), shape[0])
- cs = [c.eval() for c in cs]
- self.assertAllEqual(cs, data)
-
- def testGradientsAxis0(self):
- for use_gpu in False, True:
+ with self.test_session():
for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2):
data = np.random.randn(*shape)
- shapes = [shape[1:]] * shape[0]
- for i in xrange(shape[0]):
- with self.test_session(use_gpu=use_gpu):
- x = tf.constant(data)
- cs = tf.unpack(x, num=shape[0])
- err = tf.test.compute_gradient_error(x, shape, cs[i], shapes[i])
- self.assertLess(err, 1e-6)
+ # Convert data to a single tensorflow tensor
+ x = tf.constant(data)
+ # Unpack into a list of tensors
+ cs = tf.unpack(x, num=shape[0])
+ self.assertEqual(type(cs), list)
+ self.assertEqual(len(cs), shape[0])
+ cs = [c.eval() for c in cs]
+ self.assertAllEqual(cs, data)
+
+ def testGradientsAxis0(self):
+ for shape in (2,), (3,), (2, 3), (3, 2), (4, 3, 2):
+ data = np.random.randn(*shape)
+ shapes = [shape[1:]] * shape[0]
+ for i in xrange(shape[0]):
+ with self.test_session():
+ x = tf.constant(data)
+ cs = tf.unpack(x, num=shape[0])
+ err = tf.test.compute_gradient_error(x, shape, cs[i], shapes[i])
+ self.assertLess(err, 1e-6)
def testGradientsAxis1(self):
- for use_gpu in False, True:
- for shape in (2, 3), (3, 2), (4, 3, 2):
- data = np.random.randn(*shape)
- out_shape = list(shape)
- del out_shape[1]
- for i in xrange(shape[1]):
- with self.test_session(use_gpu=use_gpu):
- x = tf.constant(data)
- cs = tf.unpack(x, num=shape[1], axis=1)
- err = tf.test.compute_gradient_error(x, shape, cs[i], out_shape)
- self.assertLess(err, 1e-6)
+ for shape in (2, 3), (3, 2), (4, 3, 2):
+ data = np.random.randn(*shape)
+ out_shape = list(shape)
+ del out_shape[1]
+ for i in xrange(shape[1]):
+ with self.test_session():
+ x = tf.constant(data)
+ cs = tf.unpack(x, num=shape[1], axis=1)
+ err = tf.test.compute_gradient_error(x, shape, cs[i], out_shape)
+ self.assertLess(err, 1e-6)
def testInferNum(self):
with self.test_session():