def set_key_vars(self, restore_scope_exclude, train_scopes):
"""Set critical variables for relevant tasks.
Set vars_to_train and vars_to_restore.
Called after build_model.
Args:
restore_scope_exclude: variable scopes to exclude for restoring.
train_scopes: variable scopes to train.
"""
# self.dm_model.use_graph()
self.vars_to_restore = slim.get_variables_to_restore(
exclude=restore_scope_exclude)
self.vars_to_train = []
if train_scopes is not None:
for scope in train_scopes:
variables = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope)
self.vars_to_train.extend(variables)
if not self.vars_to_train:
print "[set_key_vars: info] No variables to train were defined." \
" Will train ALL variables."
self.vars_to_train = None
#base_model.print_variable_names(self.vars_to_train)
评论列表
文章目录