Commit 461fc094 authored by Haiyang Kong's avatar Haiyang Kong Committed by Taylor Robie
Browse files

Make codes more pythonic. (#4213)

* Make codes more pythonic.

* Restore the indents

Restore the indents.
parent ea6d6aab
...@@ -999,12 +999,10 @@ ...@@ -999,12 +999,10 @@
"\n", "\n",
" variables_to_restore = []\n", " variables_to_restore = []\n",
" for var in slim.get_model_variables():\n", " for var in slim.get_model_variables():\n",
" excluded = False\n",
" for exclusion in exclusions:\n", " for exclusion in exclusions:\n",
" if var.op.name.startswith(exclusion):\n", " if var.op.name.startswith(exclusion):\n",
" excluded = True\n",
" break\n", " break\n",
" if not excluded:\n", " else:\n",
" variables_to_restore.append(var)\n", " variables_to_restore.append(var)\n",
"\n", "\n",
" return slim.assign_from_checkpoint_fn(\n", " return slim.assign_from_checkpoint_fn(\n",
......
...@@ -340,12 +340,10 @@ def _get_init_fn(): ...@@ -340,12 +340,10 @@ def _get_init_fn():
# TODO(sguada) variables.filter_variables() # TODO(sguada) variables.filter_variables()
variables_to_restore = [] variables_to_restore = []
for var in slim.get_model_variables(): for var in slim.get_model_variables():
excluded = False
for exclusion in exclusions: for exclusion in exclusions:
if var.op.name.startswith(exclusion): if var.op.name.startswith(exclusion):
excluded = True
break break
if not excluded: else:
variables_to_restore.append(var) variables_to_restore.append(var)
if tf.gfile.IsDirectory(FLAGS.checkpoint_path): if tf.gfile.IsDirectory(FLAGS.checkpoint_path):
...@@ -552,7 +550,6 @@ def main(_): ...@@ -552,7 +550,6 @@ def main(_):
# Merge all summaries together. # Merge all summaries together.
summary_op = tf.summary.merge(list(summaries), name='summary_op') summary_op = tf.summary.merge(list(summaries), name='summary_op')
########################### ###########################
# Kicks off the training. # # Kicks off the training. #
########################### ###########################
......
...@@ -71,12 +71,10 @@ class InitFromPretrainedCheckpointHook(session_run_hook.SessionRunHook): ...@@ -71,12 +71,10 @@ class InitFromPretrainedCheckpointHook(session_run_hook.SessionRunHook):
# Variable filtering by given exclude_scopes. # Variable filtering by given exclude_scopes.
filtered_variables_to_restore = {} filtered_variables_to_restore = {}
for v in variable_to_restore: for v in variable_to_restore:
excluded = False
for exclusion in exclusions: for exclusion in exclusions:
if v.name.startswith(exclusion): if v.name.startswith(exclusion):
excluded = True
break break
if not excluded: else:
var_name = v.name.split(':')[0] var_name = v.name.split(':')[0]
filtered_variables_to_restore[var_name] = v filtered_variables_to_restore[var_name] = v
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment