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 @@
"\n",
" variables_to_restore = []\n",
" for var in slim.get_model_variables():\n",
" excluded = False\n",
" for exclusion in exclusions:\n",
" if var.op.name.startswith(exclusion):\n",
" excluded = True\n",
" break\n",
" if not excluded:\n",
" else:\n",
" variables_to_restore.append(var)\n",
"\n",
" return slim.assign_from_checkpoint_fn(\n",
......
......@@ -340,12 +340,10 @@ def _get_init_fn():
# TODO(sguada) variables.filter_variables()
variables_to_restore = []
for var in slim.get_model_variables():
excluded = False
for exclusion in exclusions:
if var.op.name.startswith(exclusion):
excluded = True
break
if not excluded:
else:
variables_to_restore.append(var)
if tf.gfile.IsDirectory(FLAGS.checkpoint_path):
......@@ -552,7 +550,6 @@ def main(_):
# Merge all summaries together.
summary_op = tf.summary.merge(list(summaries), name='summary_op')
###########################
# Kicks off the training. #
###########################
......
......@@ -71,12 +71,10 @@ class InitFromPretrainedCheckpointHook(session_run_hook.SessionRunHook):
# Variable filtering by given exclude_scopes.
filtered_variables_to_restore = {}
for v in variable_to_restore:
excluded = False
for exclusion in exclusions:
if v.name.startswith(exclusion):
excluded = True
break
if not excluded:
else:
var_name = v.name.split(':')[0]
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