From 890e16594a005fe703a5556530b0dc3e6527fa47 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 10 Sep 2018 14:36:26 -0700 Subject: Move from deprecated self.test_session() to self.cached_session(). self.test_session() has been deprecated in 9962eb5e84b15e309410071b06c2ed2d6148ed44 as its name confuses readers of the test. Moving to cached_session() instead which is more explicit about: * the fact that the session may be reused. * the session is not closed even when doing a "with self.test_session()" statement. PiperOrigin-RevId: 212336321 --- .../tools/compatibility/testdata/test_file_v0_11.py | 16 ++++++++-------- .../tools/compatibility/testdata/test_file_v1_10.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tensorflow/tools/compatibility') diff --git a/tensorflow/tools/compatibility/testdata/test_file_v0_11.py b/tensorflow/tools/compatibility/testdata/test_file_v0_11.py index 01f37d8768..35a74c9664 100644 --- a/tensorflow/tools/compatibility/testdata/test_file_v0_11.py +++ b/tensorflow/tools/compatibility/testdata/test_file_v0_11.py @@ -35,7 +35,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): """ def testArgRenames(self): - with self.test_session(): + with self.cached_session(): a = [[1., 2., 3.], [4., 5., 6.]] b = [[True, False, False], [False, True, True]] @@ -98,7 +98,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): [[[1, 2]], [[3, 4]]]) def testArgMinMax(self): - with self.test_session(): + with self.cached_session(): self.assertAllEqual( tf.argmin([[1, 2, 3], [4, 1, 0]], dimension=1).eval(), [0, 2]) @@ -113,7 +113,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): [1, 0, 0]) def testExpandAndSqueeze(self): - with self.test_session(): + with self.cached_session(): # TODO(aselle): sparse_split, sparse_reduce_sum, # sparse_reduce_sum_sparse, reduce_join @@ -140,7 +140,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): a) def testArithmeticRenames(self): - with self.test_session() as s: + with self.cached_session() as s: stuff = tf.split(1, 2, [[1, 2, 3, 4], [4, 5, 6, 7]]) vals = s.run(stuff) self.assertAllEqual(vals, @@ -164,7 +164,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): # ] def testBatchAndSvd(self): - with self.test_session(): + with self.cached_session(): mat = [[1., 2.], [2., 3.]] batched_mat = tf.expand_dims(mat, [0]) result = tf.matmul(mat, mat).eval() @@ -176,7 +176,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): def testCrossEntropy(self): # TODO(aselle): Test sparse_softmax_... - with self.test_session(): + with self.cached_session(): labels = [.8, .5, .2, .1] logits = [.9, .1, .3, .1] self.assertAllEqual( @@ -191,7 +191,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): labels=labels, logits=logits).eval()) def testVariables(self): - with self.test_session() as s: + with self.cached_session() as s: # make some variables _ = [tf.Variable([1, 2, 3], dtype=tf.float32), @@ -201,7 +201,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): _ = [v.name for v in tf.local_variables()] def testSummaries(self): - with self.test_session() as s: + with self.cached_session() as s: var = tf.Variable([1, 2, 3], dtype=tf.float32) s.run(tf.initialize_all_variables()) x, y = np.meshgrid(np.linspace(-10, 10, 256), np.linspace(-10, 10, 256)) diff --git a/tensorflow/tools/compatibility/testdata/test_file_v1_10.py b/tensorflow/tools/compatibility/testdata/test_file_v1_10.py index a49035a1a0..e5ca8d3e2e 100644 --- a/tensorflow/tools/compatibility/testdata/test_file_v1_10.py +++ b/tensorflow/tools/compatibility/testdata/test_file_v1_10.py @@ -26,7 +26,7 @@ class TestUpgrade(test_util.TensorFlowTestCase): """Test various APIs that have been changed in 2.0.""" def testRenames(self): - with self.test_session(): + with self.cached_session(): self.assertAllClose(1.04719755, tf.acos(0.5).eval()) self.assertAllClose(0.5, tf.rsqrt(4.0).eval()) -- cgit v1.2.3