Skip to content

Commit 461fc09

Browse files
KongseaTaylor Robie
authored and
Taylor Robie
committed
Make codes more pythonic. (tensorflow#4213)
* Make codes more pythonic. * Restore the indents Restore the indents.
1 parent ea6d6aa commit 461fc09

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

research/slim/slim_walkthrough.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,12 +999,10 @@
999999
"\n",
10001000
" variables_to_restore = []\n",
10011001
" for var in slim.get_model_variables():\n",
1002-
" excluded = False\n",
10031002
" for exclusion in exclusions:\n",
10041003
" if var.op.name.startswith(exclusion):\n",
1005-
" excluded = True\n",
10061004
" break\n",
1007-
" if not excluded:\n",
1005+
" else:\n",
10081006
" variables_to_restore.append(var)\n",
10091007
"\n",
10101008
" return slim.assign_from_checkpoint_fn(\n",

research/slim/train_image_classifier.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,10 @@ def _get_init_fn():
340340
# TODO(sguada) variables.filter_variables()
341341
variables_to_restore = []
342342
for var in slim.get_model_variables():
343-
excluded = False
344343
for exclusion in exclusions:
345344
if var.op.name.startswith(exclusion):
346-
excluded = True
347345
break
348-
if not excluded:
346+
else:
349347
variables_to_restore.append(var)
350348

351349
if tf.gfile.IsDirectory(FLAGS.checkpoint_path):
@@ -552,7 +550,6 @@ def clone_fn(batch_queue):
552550
# Merge all summaries together.
553551
summary_op = tf.summary.merge(list(summaries), name='summary_op')
554552

555-
556553
###########################
557554
# Kicks off the training. #
558555
###########################

research/tcn/estimators/base_estimator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ def begin(self):
7171
# Variable filtering by given exclude_scopes.
7272
filtered_variables_to_restore = {}
7373
for v in variable_to_restore:
74-
excluded = False
7574
for exclusion in exclusions:
7675
if v.name.startswith(exclusion):
77-
excluded = True
7876
break
79-
if not excluded:
77+
else:
8078
var_name = v.name.split(':')[0]
8179
filtered_variables_to_restore[var_name] = v
8280

0 commit comments

Comments
 (0)