diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-08-21 19:10:12 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-08-21 19:19:21 -0700 |
commit | 361a82d73a50a800510674b3aaa20e4845e56434 (patch) | |
tree | 01a4167956467298ac7ab5ff1f65480c394db190 /tensorflow/contrib/slim | |
parent | 59fa06466894daf708f40368cd2ee56ed4d160c9 (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: 209700671
Diffstat (limited to 'tensorflow/contrib/slim')
8 files changed, 65 insertions, 65 deletions
diff --git a/tensorflow/contrib/slim/python/slim/nets/alexnet_test.py b/tensorflow/contrib/slim/python/slim/nets/alexnet_test.py index eb93f753ae..b6d1afd27d 100644 --- a/tensorflow/contrib/slim/python/slim/nets/alexnet_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/alexnet_test.py @@ -33,7 +33,7 @@ class AlexnetV2Test(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = alexnet.alexnet_v2(inputs, num_classes) self.assertEquals(logits.op.name, 'alexnet_v2/fc8/squeezed') @@ -44,7 +44,7 @@ class AlexnetV2Test(test.TestCase): batch_size = 1 height, width = 300, 400 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = alexnet.alexnet_v2(inputs, num_classes, spatial_squeeze=False) self.assertEquals(logits.op.name, 'alexnet_v2/fc8/BiasAdd') @@ -55,7 +55,7 @@ class AlexnetV2Test(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) _, end_points = alexnet.alexnet_v2(inputs, num_classes) expected_names = [ @@ -70,7 +70,7 @@ class AlexnetV2Test(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) alexnet.alexnet_v2(inputs, num_classes) expected_names = [ @@ -98,7 +98,7 @@ class AlexnetV2Test(test.TestCase): batch_size = 2 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): eval_inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = alexnet.alexnet_v2(eval_inputs, is_training=False) self.assertListEqual(logits.get_shape().as_list(), @@ -112,7 +112,7 @@ class AlexnetV2Test(test.TestCase): train_height, train_width = 224, 224 eval_height, eval_width = 300, 400 num_classes = 1000 - with self.test_session(): + with self.cached_session(): train_inputs = random_ops.random_uniform( (train_batch_size, train_height, train_width, 3)) logits, _ = alexnet.alexnet_v2(train_inputs) @@ -132,7 +132,7 @@ class AlexnetV2Test(test.TestCase): def testForward(self): batch_size = 1 height, width = 224, 224 - with self.test_session() as sess: + with self.cached_session() as sess: inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = alexnet.alexnet_v2(inputs) sess.run(variables.global_variables_initializer()) diff --git a/tensorflow/contrib/slim/python/slim/nets/inception_v1_test.py b/tensorflow/contrib/slim/python/slim/nets/inception_v1_test.py index 7a3d1c9703..34f12d7591 100644 --- a/tensorflow/contrib/slim/python/slim/nets/inception_v1_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/inception_v1_test.py @@ -143,7 +143,7 @@ class InceptionV1Test(test.TestCase): height, width = 224, 224 num_classes = 1000 input_np = np.random.uniform(0, 1, (batch_size, height, width, 3)) - with self.test_session() as sess: + with self.cached_session() as sess: inputs = array_ops.placeholder( dtypes.float32, shape=(batch_size, None, None, 3)) logits, end_points = inception_v1.inception_v1(inputs, num_classes) @@ -167,7 +167,7 @@ class InceptionV1Test(test.TestCase): self.assertListEqual(logits.get_shape().as_list(), [None, num_classes]) images = random_ops.random_uniform((batch_size, height, width, 3)) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(logits, {inputs: images.eval()}) self.assertEquals(output.shape, (batch_size, num_classes)) @@ -182,7 +182,7 @@ class InceptionV1Test(test.TestCase): eval_inputs, num_classes, is_training=False) predictions = math_ops.argmax(logits, 1) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (batch_size,)) @@ -200,7 +200,7 @@ class InceptionV1Test(test.TestCase): logits, _ = inception_v1.inception_v1(eval_inputs, num_classes, reuse=True) predictions = math_ops.argmax(logits, 1) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (eval_batch_size,)) @@ -211,7 +211,7 @@ class InceptionV1Test(test.TestCase): logits, _ = inception_v1.inception_v1( images, num_classes=num_classes, spatial_squeeze=False) - with self.test_session() as sess: + with self.cached_session() as sess: variables.global_variables_initializer().run() logits_out = sess.run(logits) self.assertListEqual(list(logits_out.shape), [1, 1, 1, num_classes]) diff --git a/tensorflow/contrib/slim/python/slim/nets/inception_v2_test.py b/tensorflow/contrib/slim/python/slim/nets/inception_v2_test.py index 5fbc9e5aa3..66effba944 100644 --- a/tensorflow/contrib/slim/python/slim/nets/inception_v2_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/inception_v2_test.py @@ -196,7 +196,7 @@ class InceptionV2Test(test.TestCase): height, width = 224, 224 num_classes = 1000 input_np = np.random.uniform(0, 1, (batch_size, height, width, 3)) - with self.test_session() as sess: + with self.cached_session() as sess: inputs = array_ops.placeholder( dtypes.float32, shape=(batch_size, None, None, 3)) logits, end_points = inception_v2.inception_v2(inputs, num_classes) @@ -220,7 +220,7 @@ class InceptionV2Test(test.TestCase): self.assertListEqual(logits.get_shape().as_list(), [None, num_classes]) images = random_ops.random_uniform((batch_size, height, width, 3)) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(logits, {inputs: images.eval()}) self.assertEquals(output.shape, (batch_size, num_classes)) @@ -235,7 +235,7 @@ class InceptionV2Test(test.TestCase): eval_inputs, num_classes, is_training=False) predictions = math_ops.argmax(logits, 1) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (batch_size,)) @@ -253,7 +253,7 @@ class InceptionV2Test(test.TestCase): logits, _ = inception_v2.inception_v2(eval_inputs, num_classes, reuse=True) predictions = math_ops.argmax(logits, 1) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (eval_batch_size,)) @@ -264,7 +264,7 @@ class InceptionV2Test(test.TestCase): logits, _ = inception_v2.inception_v2( images, num_classes=num_classes, spatial_squeeze=False) - with self.test_session() as sess: + with self.cached_session() as sess: variables.global_variables_initializer().run() logits_out = sess.run(logits) self.assertListEqual(list(logits_out.shape), [1, 1, 1, num_classes]) diff --git a/tensorflow/contrib/slim/python/slim/nets/inception_v3_test.py b/tensorflow/contrib/slim/python/slim/nets/inception_v3_test.py index 6ba02318ed..0f9cca7bbd 100644 --- a/tensorflow/contrib/slim/python/slim/nets/inception_v3_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/inception_v3_test.py @@ -226,7 +226,7 @@ class InceptionV3Test(test.TestCase): height, width = 299, 299 num_classes = 1000 input_np = np.random.uniform(0, 1, (batch_size, height, width, 3)) - with self.test_session() as sess: + with self.cached_session() as sess: inputs = array_ops.placeholder( dtypes.float32, shape=(batch_size, None, None, 3)) logits, end_points = inception_v3.inception_v3(inputs, num_classes) @@ -249,7 +249,7 @@ class InceptionV3Test(test.TestCase): self.assertListEqual(logits.get_shape().as_list(), [None, num_classes]) images = random_ops.random_uniform((batch_size, height, width, 3)) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(logits, {inputs: images.eval()}) self.assertEquals(output.shape, (batch_size, num_classes)) @@ -264,7 +264,7 @@ class InceptionV3Test(test.TestCase): eval_inputs, num_classes, is_training=False) predictions = math_ops.argmax(logits, 1) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (batch_size,)) @@ -283,7 +283,7 @@ class InceptionV3Test(test.TestCase): eval_inputs, num_classes, is_training=False, reuse=True) predictions = math_ops.argmax(logits, 1) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (eval_batch_size,)) @@ -294,7 +294,7 @@ class InceptionV3Test(test.TestCase): logits, _ = inception_v3.inception_v3( images, num_classes=num_classes, spatial_squeeze=False) - with self.test_session() as sess: + with self.cached_session() as sess: variables.global_variables_initializer().run() logits_out = sess.run(logits) self.assertListEqual(list(logits_out.shape), [1, 1, 1, num_classes]) diff --git a/tensorflow/contrib/slim/python/slim/nets/overfeat_test.py b/tensorflow/contrib/slim/python/slim/nets/overfeat_test.py index 317af3cb29..44fa35ad14 100644 --- a/tensorflow/contrib/slim/python/slim/nets/overfeat_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/overfeat_test.py @@ -33,7 +33,7 @@ class OverFeatTest(test.TestCase): batch_size = 5 height, width = 231, 231 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = overfeat.overfeat(inputs, num_classes) self.assertEquals(logits.op.name, 'overfeat/fc8/squeezed') @@ -44,7 +44,7 @@ class OverFeatTest(test.TestCase): batch_size = 1 height, width = 281, 281 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = overfeat.overfeat(inputs, num_classes, spatial_squeeze=False) self.assertEquals(logits.op.name, 'overfeat/fc8/BiasAdd') @@ -55,7 +55,7 @@ class OverFeatTest(test.TestCase): batch_size = 5 height, width = 231, 231 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) _, end_points = overfeat.overfeat(inputs, num_classes) expected_names = [ @@ -70,7 +70,7 @@ class OverFeatTest(test.TestCase): batch_size = 5 height, width = 231, 231 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) overfeat.overfeat(inputs, num_classes) expected_names = [ @@ -98,7 +98,7 @@ class OverFeatTest(test.TestCase): batch_size = 2 height, width = 231, 231 num_classes = 1000 - with self.test_session(): + with self.cached_session(): eval_inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = overfeat.overfeat(eval_inputs, is_training=False) self.assertListEqual(logits.get_shape().as_list(), @@ -112,7 +112,7 @@ class OverFeatTest(test.TestCase): train_height, train_width = 231, 231 eval_height, eval_width = 281, 281 num_classes = 1000 - with self.test_session(): + with self.cached_session(): train_inputs = random_ops.random_uniform( (train_batch_size, train_height, train_width, 3)) logits, _ = overfeat.overfeat(train_inputs) @@ -132,7 +132,7 @@ class OverFeatTest(test.TestCase): def testForward(self): batch_size = 1 height, width = 231, 231 - with self.test_session() as sess: + with self.cached_session() as sess: inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = overfeat.overfeat(inputs) sess.run(variables.global_variables_initializer()) diff --git a/tensorflow/contrib/slim/python/slim/nets/resnet_v1_test.py b/tensorflow/contrib/slim/python/slim/nets/resnet_v1_test.py index 576444214d..8ff44fe4b5 100644 --- a/tensorflow/contrib/slim/python/slim/nets/resnet_v1_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/resnet_v1_test.py @@ -69,7 +69,7 @@ class ResnetUtilsTest(test.TestCase): x = resnet_utils.subsample(x, 2) expected = array_ops.reshape( constant_op.constant([0, 2, 6, 8]), [1, 2, 2, 1]) - with self.test_session(): + with self.cached_session(): self.assertAllClose(x.eval(), expected.eval()) def testSubsampleFourByFour(self): @@ -77,7 +77,7 @@ class ResnetUtilsTest(test.TestCase): x = resnet_utils.subsample(x, 2) expected = array_ops.reshape( constant_op.constant([0, 2, 8, 10]), [1, 2, 2, 1]) - with self.test_session(): + with self.cached_session(): self.assertAllClose(x.eval(), expected.eval()) def testConv2DSameEven(self): @@ -110,7 +110,7 @@ class ResnetUtilsTest(test.TestCase): y4_expected = math_ops.to_float([[48, 37], [37, 22]]) y4_expected = array_ops.reshape(y4_expected, [1, n2, n2, 1]) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) self.assertAllClose(y1.eval(), y1_expected.eval()) self.assertAllClose(y2.eval(), y2_expected.eval()) @@ -148,7 +148,7 @@ class ResnetUtilsTest(test.TestCase): y4 = layers.conv2d(x, 1, [3, 3], stride=2, scope='Conv') y4_expected = y2_expected - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) self.assertAllClose(y1.eval(), y1_expected.eval()) self.assertAllClose(y2.eval(), y2_expected.eval()) @@ -223,7 +223,7 @@ class ResnetUtilsTest(test.TestCase): with arg_scope([layers.batch_norm], is_training=False): for output_stride in [1, 2, 4, 8, None]: with ops.Graph().as_default(): - with self.test_session() as sess: + with self.cached_session() as sess: random_seed.set_random_seed(0) inputs = create_test_input(1, height, width, 3) # Dense feature extraction followed by subsampling. @@ -364,7 +364,7 @@ class ResnetCompleteNetworkTest(test.TestCase): for output_stride in [4, 8, 16, 32, None]: with arg_scope(resnet_utils.resnet_arg_scope()): with ops.Graph().as_default(): - with self.test_session() as sess: + with self.cached_session() as sess: random_seed.set_random_seed(0) inputs = create_test_input(2, 81, 81, 3) # Dense feature extraction followed by subsampling. @@ -401,7 +401,7 @@ class ResnetCompleteNetworkTest(test.TestCase): self.assertListEqual(logits.get_shape().as_list(), [None, 1, 1, num_classes]) images = create_test_input(batch, height, width, 3) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(logits, {inputs: images.eval()}) self.assertEqual(output.shape, (batch, 1, 1, num_classes)) @@ -415,7 +415,7 @@ class ResnetCompleteNetworkTest(test.TestCase): output, _ = self._resnet_small(inputs, None, global_pool=global_pool) self.assertListEqual(output.get_shape().as_list(), [batch, None, None, 32]) images = create_test_input(batch, height, width, 3) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(output, {inputs: images.eval()}) self.assertEqual(output.shape, (batch, 3, 3, 32)) @@ -431,7 +431,7 @@ class ResnetCompleteNetworkTest(test.TestCase): inputs, None, global_pool=global_pool, output_stride=output_stride) self.assertListEqual(output.get_shape().as_list(), [batch, None, None, 32]) images = create_test_input(batch, height, width, 3) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(output, {inputs: images.eval()}) self.assertEqual(output.shape, (batch, 9, 9, 32)) diff --git a/tensorflow/contrib/slim/python/slim/nets/resnet_v2_test.py b/tensorflow/contrib/slim/python/slim/nets/resnet_v2_test.py index 6bdda18c5b..055ecff1c3 100644 --- a/tensorflow/contrib/slim/python/slim/nets/resnet_v2_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/resnet_v2_test.py @@ -69,7 +69,7 @@ class ResnetUtilsTest(test.TestCase): x = resnet_utils.subsample(x, 2) expected = array_ops.reshape( constant_op.constant([0, 2, 6, 8]), [1, 2, 2, 1]) - with self.test_session(): + with self.cached_session(): self.assertAllClose(x.eval(), expected.eval()) def testSubsampleFourByFour(self): @@ -77,7 +77,7 @@ class ResnetUtilsTest(test.TestCase): x = resnet_utils.subsample(x, 2) expected = array_ops.reshape( constant_op.constant([0, 2, 8, 10]), [1, 2, 2, 1]) - with self.test_session(): + with self.cached_session(): self.assertAllClose(x.eval(), expected.eval()) def testConv2DSameEven(self): @@ -110,7 +110,7 @@ class ResnetUtilsTest(test.TestCase): y4_expected = math_ops.to_float([[48, 37], [37, 22]]) y4_expected = array_ops.reshape(y4_expected, [1, n2, n2, 1]) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) self.assertAllClose(y1.eval(), y1_expected.eval()) self.assertAllClose(y2.eval(), y2_expected.eval()) @@ -151,7 +151,7 @@ class ResnetUtilsTest(test.TestCase): y4 = layers.conv2d(x, 1, [3, 3], stride=2, scope='Conv') y4_expected = y2_expected - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) self.assertAllClose(y1.eval(), y1_expected.eval()) self.assertAllClose(y2.eval(), y2_expected.eval()) @@ -227,7 +227,7 @@ class ResnetUtilsTest(test.TestCase): with arg_scope([layers.batch_norm], is_training=False): for output_stride in [1, 2, 4, 8, None]: with ops.Graph().as_default(): - with self.test_session() as sess: + with self.cached_session() as sess: random_seed.set_random_seed(0) inputs = create_test_input(1, height, width, 3) # Dense feature extraction followed by subsampling. @@ -368,7 +368,7 @@ class ResnetCompleteNetworkTest(test.TestCase): for output_stride in [4, 8, 16, 32, None]: with arg_scope(resnet_utils.resnet_arg_scope()): with ops.Graph().as_default(): - with self.test_session() as sess: + with self.cached_session() as sess: random_seed.set_random_seed(0) inputs = create_test_input(2, 81, 81, 3) # Dense feature extraction followed by subsampling. @@ -405,7 +405,7 @@ class ResnetCompleteNetworkTest(test.TestCase): self.assertListEqual(logits.get_shape().as_list(), [None, 1, 1, num_classes]) images = create_test_input(batch, height, width, 3) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(logits, {inputs: images.eval()}) self.assertEqual(output.shape, (batch, 1, 1, num_classes)) @@ -419,7 +419,7 @@ class ResnetCompleteNetworkTest(test.TestCase): output, _ = self._resnet_small(inputs, None, global_pool=global_pool) self.assertListEqual(output.get_shape().as_list(), [batch, None, None, 32]) images = create_test_input(batch, height, width, 3) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(output, {inputs: images.eval()}) self.assertEqual(output.shape, (batch, 3, 3, 32)) @@ -435,7 +435,7 @@ class ResnetCompleteNetworkTest(test.TestCase): inputs, None, global_pool=global_pool, output_stride=output_stride) self.assertListEqual(output.get_shape().as_list(), [batch, None, None, 32]) images = create_test_input(batch, height, width, 3) - with self.test_session() as sess: + with self.cached_session() as sess: sess.run(variables.global_variables_initializer()) output = sess.run(output, {inputs: images.eval()}) self.assertEqual(output.shape, (batch, 9, 9, 32)) diff --git a/tensorflow/contrib/slim/python/slim/nets/vgg_test.py b/tensorflow/contrib/slim/python/slim/nets/vgg_test.py index 36628b32d1..71ce4b89cd 100644 --- a/tensorflow/contrib/slim/python/slim/nets/vgg_test.py +++ b/tensorflow/contrib/slim/python/slim/nets/vgg_test.py @@ -34,7 +34,7 @@ class VGGATest(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_a(inputs, num_classes) self.assertEquals(logits.op.name, 'vgg_a/fc8/squeezed') @@ -45,7 +45,7 @@ class VGGATest(test.TestCase): batch_size = 1 height, width = 256, 256 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_a(inputs, num_classes, spatial_squeeze=False) self.assertEquals(logits.op.name, 'vgg_a/fc8/BiasAdd') @@ -73,7 +73,7 @@ class VGGATest(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) vgg.vgg_a(inputs, num_classes) expected_names = [ @@ -107,7 +107,7 @@ class VGGATest(test.TestCase): batch_size = 2 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): eval_inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_a(eval_inputs, is_training=False) self.assertListEqual(logits.get_shape().as_list(), @@ -121,7 +121,7 @@ class VGGATest(test.TestCase): train_height, train_width = 224, 224 eval_height, eval_width = 256, 256 num_classes = 1000 - with self.test_session(): + with self.cached_session(): train_inputs = random_ops.random_uniform( (train_batch_size, train_height, train_width, 3)) logits, _ = vgg.vgg_a(train_inputs) @@ -141,7 +141,7 @@ class VGGATest(test.TestCase): def testForward(self): batch_size = 1 height, width = 224, 224 - with self.test_session() as sess: + with self.cached_session() as sess: inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_a(inputs) sess.run(variables.global_variables_initializer()) @@ -155,7 +155,7 @@ class VGG16Test(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_16(inputs, num_classes) self.assertEquals(logits.op.name, 'vgg_16/fc8/squeezed') @@ -166,7 +166,7 @@ class VGG16Test(test.TestCase): batch_size = 1 height, width = 256, 256 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_16(inputs, num_classes, spatial_squeeze=False) self.assertEquals(logits.op.name, 'vgg_16/fc8/BiasAdd') @@ -197,7 +197,7 @@ class VGG16Test(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) vgg.vgg_16(inputs, num_classes) expected_names = [ @@ -241,7 +241,7 @@ class VGG16Test(test.TestCase): batch_size = 2 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): eval_inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_16(eval_inputs, is_training=False) self.assertListEqual(logits.get_shape().as_list(), @@ -255,7 +255,7 @@ class VGG16Test(test.TestCase): train_height, train_width = 224, 224 eval_height, eval_width = 256, 256 num_classes = 1000 - with self.test_session(): + with self.cached_session(): train_inputs = random_ops.random_uniform( (train_batch_size, train_height, train_width, 3)) logits, _ = vgg.vgg_16(train_inputs) @@ -275,7 +275,7 @@ class VGG16Test(test.TestCase): def testForward(self): batch_size = 1 height, width = 224, 224 - with self.test_session() as sess: + with self.cached_session() as sess: inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_16(inputs) sess.run(variables.global_variables_initializer()) @@ -289,7 +289,7 @@ class VGG19Test(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_19(inputs, num_classes) self.assertEquals(logits.op.name, 'vgg_19/fc8/squeezed') @@ -300,7 +300,7 @@ class VGG19Test(test.TestCase): batch_size = 1 height, width = 256, 256 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_19(inputs, num_classes, spatial_squeeze=False) self.assertEquals(logits.op.name, 'vgg_19/fc8/BiasAdd') @@ -332,7 +332,7 @@ class VGG19Test(test.TestCase): batch_size = 5 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): inputs = random_ops.random_uniform((batch_size, height, width, 3)) vgg.vgg_19(inputs, num_classes) expected_names = [ @@ -382,7 +382,7 @@ class VGG19Test(test.TestCase): batch_size = 2 height, width = 224, 224 num_classes = 1000 - with self.test_session(): + with self.cached_session(): eval_inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_19(eval_inputs, is_training=False) self.assertListEqual(logits.get_shape().as_list(), @@ -396,7 +396,7 @@ class VGG19Test(test.TestCase): train_height, train_width = 224, 224 eval_height, eval_width = 256, 256 num_classes = 1000 - with self.test_session(): + with self.cached_session(): train_inputs = random_ops.random_uniform( (train_batch_size, train_height, train_width, 3)) logits, _ = vgg.vgg_19(train_inputs) @@ -416,7 +416,7 @@ class VGG19Test(test.TestCase): def testForward(self): batch_size = 1 height, width = 224, 224 - with self.test_session() as sess: + with self.cached_session() as sess: inputs = random_ops.random_uniform((batch_size, height, width, 3)) logits, _ = vgg.vgg_19(inputs) sess.run(variables.global_variables_initializer()) |