From 8f8b2497dbccf4b33557088b82b562205aa47c36 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 12 Sep 2018 16:35:07 -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: 212725342 --- tensorflow/examples/speech_commands/freeze_test.py | 6 +++--- tensorflow/examples/speech_commands/input_data_test.py | 4 ++-- tensorflow/examples/speech_commands/label_wav_test.py | 2 +- tensorflow/examples/speech_commands/models_test.py | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'tensorflow/examples') diff --git a/tensorflow/examples/speech_commands/freeze_test.py b/tensorflow/examples/speech_commands/freeze_test.py index c8de6c2152..0c7ca9bc01 100644 --- a/tensorflow/examples/speech_commands/freeze_test.py +++ b/tensorflow/examples/speech_commands/freeze_test.py @@ -25,7 +25,7 @@ from tensorflow.python.platform import test class FreezeTest(test.TestCase): def testCreateInferenceGraphWithMfcc(self): - with self.test_session() as sess: + with self.cached_session() as sess: freeze.create_inference_graph( wanted_words='a,b,c,d', sample_rate=16000, @@ -44,7 +44,7 @@ class FreezeTest(test.TestCase): self.assertEqual(1, ops.count('Mfcc')) def testCreateInferenceGraphWithoutMfcc(self): - with self.test_session() as sess: + with self.cached_session() as sess: freeze.create_inference_graph( wanted_words='a,b,c,d', sample_rate=16000, @@ -63,7 +63,7 @@ class FreezeTest(test.TestCase): self.assertEqual(0, ops.count('Mfcc')) def testFeatureBinCount(self): - with self.test_session() as sess: + with self.cached_session() as sess: freeze.create_inference_graph( wanted_words='a,b,c,d', sample_rate=16000, diff --git a/tensorflow/examples/speech_commands/input_data_test.py b/tensorflow/examples/speech_commands/input_data_test.py index 2e551be9a2..aa4e807779 100644 --- a/tensorflow/examples/speech_commands/input_data_test.py +++ b/tensorflow/examples/speech_commands/input_data_test.py @@ -32,7 +32,7 @@ from tensorflow.python.platform import test class InputDataTest(test.TestCase): def _getWavData(self): - with self.test_session() as sess: + with self.cached_session() as sess: sample_data = tf.zeros([32000, 2]) wav_encoder = contrib_audio.encode_wav(sample_data, 16000) wav_data = sess.run(wav_encoder) @@ -75,7 +75,7 @@ class InputDataTest(test.TestCase): self._saveTestWavFile(file_path, wav_data) model_settings = models.prepare_model_settings( 4, 16000, 1000, window_length_ms, 20, 40, preprocess) - with self.test_session() as sess: + with self.cached_session() as sess: audio_processor = input_data.AudioProcessor( "", wav_dir, 10, 10, ["a", "b"], 10, 10, model_settings, tmp_dir) result_data, result_labels = audio_processor.get_data( diff --git a/tensorflow/examples/speech_commands/label_wav_test.py b/tensorflow/examples/speech_commands/label_wav_test.py index 80ca774706..f0af2a4798 100644 --- a/tensorflow/examples/speech_commands/label_wav_test.py +++ b/tensorflow/examples/speech_commands/label_wav_test.py @@ -30,7 +30,7 @@ from tensorflow.python.platform import test class LabelWavTest(test.TestCase): def _getWavData(self): - with self.test_session() as sess: + with self.cached_session() as sess: sample_data = tf.zeros([1000, 2]) wav_encoder = contrib_audio.encode_wav(sample_data, 16000) wav_data = sess.run(wav_encoder) diff --git a/tensorflow/examples/speech_commands/models_test.py b/tensorflow/examples/speech_commands/models_test.py index 0c373967ed..04478c0962 100644 --- a/tensorflow/examples/speech_commands/models_test.py +++ b/tensorflow/examples/speech_commands/models_test.py @@ -49,7 +49,7 @@ class ModelsTest(test.TestCase): def testCreateModelConvTraining(self): model_settings = self._modelSettings() - with self.test_session() as sess: + with self.cached_session() as sess: fingerprint_input = tf.zeros([1, model_settings["fingerprint_size"]]) logits, dropout_prob = models.create_model(fingerprint_input, model_settings, "conv", True) @@ -60,7 +60,7 @@ class ModelsTest(test.TestCase): def testCreateModelConvInference(self): model_settings = self._modelSettings() - with self.test_session() as sess: + with self.cached_session() as sess: fingerprint_input = tf.zeros([1, model_settings["fingerprint_size"]]) logits = models.create_model(fingerprint_input, model_settings, "conv", False) @@ -69,7 +69,7 @@ class ModelsTest(test.TestCase): def testCreateModelLowLatencyConvTraining(self): model_settings = self._modelSettings() - with self.test_session() as sess: + with self.cached_session() as sess: fingerprint_input = tf.zeros([1, model_settings["fingerprint_size"]]) logits, dropout_prob = models.create_model( fingerprint_input, model_settings, "low_latency_conv", True) @@ -80,7 +80,7 @@ class ModelsTest(test.TestCase): def testCreateModelFullyConnectedTraining(self): model_settings = self._modelSettings() - with self.test_session() as sess: + with self.cached_session() as sess: fingerprint_input = tf.zeros([1, model_settings["fingerprint_size"]]) logits, dropout_prob = models.create_model( fingerprint_input, model_settings, "single_fc", True) @@ -91,7 +91,7 @@ class ModelsTest(test.TestCase): def testCreateModelBadArchitecture(self): model_settings = self._modelSettings() - with self.test_session(): + with self.cached_session(): fingerprint_input = tf.zeros([1, model_settings["fingerprint_size"]]) with self.assertRaises(Exception) as e: models.create_model(fingerprint_input, model_settings, @@ -100,7 +100,7 @@ class ModelsTest(test.TestCase): def testCreateModelTinyConvTraining(self): model_settings = self._modelSettings() - with self.test_session() as sess: + with self.cached_session() as sess: fingerprint_input = tf.zeros([1, model_settings["fingerprint_size"]]) logits, dropout_prob = models.create_model( fingerprint_input, model_settings, "tiny_conv", True) -- cgit v1.2.3