Fix warnings and minor refactoring.
PiperOrigin-RevId: 294698198
Change-Id: I82951719bfa8d069f56792cfd9caf3a27a9f6215
diff --git a/tensorflow/examples/speech_commands/input_data.py b/tensorflow/examples/speech_commands/input_data.py
index 2006abd..2f104b9 100644
--- a/tensorflow/examples/speech_commands/input_data.py
+++ b/tensorflow/examples/speech_commands/input_data.py
@@ -217,11 +217,11 @@
"""
if not data_url:
return
- if not os.path.exists(dest_directory):
+ if not gfile.Exists(dest_directory):
os.makedirs(dest_directory)
filename = data_url.split('/')[-1]
filepath = os.path.join(dest_directory, filename)
- if not os.path.exists(filepath):
+ if not gfile.Exists(filepath):
def _progress(count, block_size, total_size):
sys.stdout.write(
@@ -350,7 +350,7 @@
"""
self.background_data = []
background_dir = os.path.join(self.data_dir, BACKGROUND_NOISE_DIR_NAME)
- if not os.path.exists(background_dir):
+ if not gfile.Exists(background_dir):
return self.background_data
with tf.compat.v1.Session(graph=tf.Graph()) as sess:
wav_filename_placeholder = tf.compat.v1.placeholder(tf.string, [])
diff --git a/tensorflow/examples/speech_commands/models_test.py b/tensorflow/examples/speech_commands/models_test.py
index cb9304e..bae5fde 100644
--- a/tensorflow/examples/speech_commands/models_test.py
+++ b/tensorflow/examples/speech_commands/models_test.py
@@ -101,7 +101,7 @@
with self.assertRaises(Exception) as e:
models.create_model(fingerprint_input, model_settings,
"bad_architecture", True)
- self.assertTrue("not recognized" in str(e.exception))
+ self.assertIn("not recognized", str(e.exception))
@test_util.run_deprecated_v1
def testCreateModelTinyConvTraining(self):
diff --git a/tensorflow/examples/speech_commands/train.py b/tensorflow/examples/speech_commands/train.py
index 2ad30fa..d28893c 100644
--- a/tensorflow/examples/speech_commands/train.py
+++ b/tensorflow/examples/speech_commands/train.py
@@ -482,23 +482,23 @@
ArgumentTypeError: Not an expected value.
"""
value = value.upper()
- if value == 'INFO':
- return tf.compat.v1.logging.INFO
- elif value == 'DEBUG':
+ if value == 'DEBUG':
return tf.compat.v1.logging.DEBUG
+ elif value == 'INFO':
+ return tf.compat.v1.logging.INFO
+ elif value == 'WARN':
+ return tf.compat.v1.logging.WARN
elif value == 'ERROR':
return tf.compat.v1.logging.ERROR
elif value == 'FATAL':
return tf.compat.v1.logging.FATAL
- elif value == 'WARN':
- return tf.compat.v1.logging.WARN
else:
raise argparse.ArgumentTypeError('Not an expected value')
parser.add_argument(
'--verbosity',
type=verbosity_arg,
default=tf.compat.v1.logging.INFO,
- help='Log verbosity. Can be "INFO", "DEBUG", "ERROR", "FATAL", or "WARN"')
+ help='Log verbosity. Can be "DEBUG", "INFO", "WARN", "ERROR", or "FATAL"')
parser.add_argument(
'--optimizer',
type=str,