diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-08-21 19:09:49 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-21 19:13:28 -0700 |
commit | 754fffb399efa6204bb8aae51ce99042cb2ab18e (patch) | |
tree | 3f3a3ecd5e25bac3a4babd9ca330f63d21fb2918 /tensorflow/examples | |
parent | 34f07dc58afcbddf3c4387cdf7c49ebb5aacf4dd (diff) |
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: 209700634
Diffstat (limited to 'tensorflow/examples')
5 files changed, 11 insertions, 11 deletions
diff --git a/tensorflow/examples/adding_an_op/cuda_op_test.py b/tensorflow/examples/adding_an_op/cuda_op_test.py index 07390bc3bf..a9aaa81e3f 100644 --- a/tensorflow/examples/adding_an_op/cuda_op_test.py +++ b/tensorflow/examples/adding_an_op/cuda_op_test.py @@ -26,7 +26,7 @@ class AddOneTest(tf.test.TestCase): def test(self): if tf.test.is_built_with_cuda(): - with self.test_session(): + with self.cached_session(): result = cuda_op.add_one([5, 4, 3, 2, 1]) self.assertAllEqual(result.eval(), [6, 5, 4, 3, 2]) diff --git a/tensorflow/examples/adding_an_op/fact_test.py b/tensorflow/examples/adding_an_op/fact_test.py index f7f17e5180..11163e7ba5 100644 --- a/tensorflow/examples/adding_an_op/fact_test.py +++ b/tensorflow/examples/adding_an_op/fact_test.py @@ -24,7 +24,7 @@ import tensorflow as tf class FactTest(tf.test.TestCase): def test(self): - with self.test_session(): + with self.cached_session(): print(tf.user_ops.my_fact().eval()) diff --git a/tensorflow/examples/adding_an_op/zero_out_1_test.py b/tensorflow/examples/adding_an_op/zero_out_1_test.py index fac486100d..342d3a020c 100644 --- a/tensorflow/examples/adding_an_op/zero_out_1_test.py +++ b/tensorflow/examples/adding_an_op/zero_out_1_test.py @@ -28,7 +28,7 @@ from tensorflow.examples.adding_an_op import zero_out_op_1 class ZeroOut1Test(tf.test.TestCase): def test(self): - with self.test_session(): + with self.cached_session(): result = zero_out_op_1.zero_out([5, 4, 3, 2, 1]) self.assertAllEqual(result.eval(), [5, 0, 0, 0, 0]) diff --git a/tensorflow/examples/adding_an_op/zero_out_2_test.py b/tensorflow/examples/adding_an_op/zero_out_2_test.py index 217bbbcffa..4504597817 100644 --- a/tensorflow/examples/adding_an_op/zero_out_2_test.py +++ b/tensorflow/examples/adding_an_op/zero_out_2_test.py @@ -29,17 +29,17 @@ from tensorflow.examples.adding_an_op import zero_out_op_2 class ZeroOut2Test(tf.test.TestCase): def test(self): - with self.test_session(): + with self.cached_session(): result = zero_out_op_2.zero_out([5, 4, 3, 2, 1]) self.assertAllEqual(result.eval(), [5, 0, 0, 0, 0]) def test_2d(self): - with self.test_session(): + with self.cached_session(): result = zero_out_op_2.zero_out([[6, 5, 4], [3, 2, 1]]) self.assertAllEqual(result.eval(), [[6, 0, 0], [0, 0, 0]]) def test_grad(self): - with self.test_session(): + with self.cached_session(): shape = (5,) x = tf.constant([5, 4, 3, 2, 1], dtype=tf.float32) y = zero_out_op_2.zero_out(x) @@ -47,7 +47,7 @@ class ZeroOut2Test(tf.test.TestCase): self.assertLess(err, 1e-4) def test_grad_2d(self): - with self.test_session(): + with self.cached_session(): shape = (2, 3) x = tf.constant([[6, 5, 4], [3, 2, 1]], dtype=tf.float32) y = zero_out_op_2.zero_out(x) diff --git a/tensorflow/examples/adding_an_op/zero_out_3_test.py b/tensorflow/examples/adding_an_op/zero_out_3_test.py index 01280caf49..15d62495aa 100644 --- a/tensorflow/examples/adding_an_op/zero_out_3_test.py +++ b/tensorflow/examples/adding_an_op/zero_out_3_test.py @@ -26,23 +26,23 @@ from tensorflow.examples.adding_an_op import zero_out_op_3 class ZeroOut3Test(tf.test.TestCase): def test(self): - with self.test_session(): + with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1]) self.assertAllEqual(result.eval(), [5, 0, 0, 0, 0]) def testAttr(self): - with self.test_session(): + with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1], preserve_index=3) self.assertAllEqual(result.eval(), [0, 0, 0, 2, 0]) def testNegative(self): - with self.test_session(): + with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1], preserve_index=-1) with self.assertRaisesOpError("Need preserve_index >= 0, got -1"): result.eval() def testLarge(self): - with self.test_session(): + with self.cached_session(): result = zero_out_op_3.zero_out([5, 4, 3, 2, 1], preserve_index=17) with self.assertRaisesOpError("preserve_index out of range"): result.eval() |