def _get_init_fn():
 if (FLAGS.checkpoint_path is None):
  return None
 if tf.train.latest_checkpoint(FLAGS.train_dir):
  tf.logging.info(('Ignoring --checkpoint_path because a checkpoint already exists in %s' % FLAGS.train_dir))
  return None
 exclusions = []
 if FLAGS.checkpoint_exclude_scopes:
  exclusions = [scope.strip() for scope in FLAGS.checkpoint_exclude_scopes.split(',')]
 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):
   variables_to_restore.append(var)
 if tf.gfile.IsDirectory(FLAGS.checkpoint_path):
  checkpoint_path = tf.train.latest_checkpoint(FLAGS.checkpoint_path)
 else:
  checkpoint_path = FLAGS.checkpoint_path
 tf.logging.info(('Fine-tuning from %s' % checkpoint_path))
 return slim.assign_from_checkpoint_fn(checkpoint_path, variables_to_restore, ignore_missing_vars=FLAGS.ignore_missing_vars)

def _get_init_fn ( ) : if ( FLAGS . checkpoint_path is None ) : return None if tf . train . latest_checkpoint ( FLAGS . train_dir ) : tf . logging . info ( ( 'Ignoring --checkpoint_path because a checkpoint already exists in %s' % FLAGS . train_dir ) ) return None exclusions = [ ] if FLAGS . checkpoint_exclude_scopes : exclusions = [ scope . strip ( ) for scope in FLAGS . checkpoint_exclude_scopes . split ( ',' ) ] 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 ) : variables_to_restore . append ( var ) if tf . gfile . IsDirectory ( FLAGS . checkpoint_path ) : checkpoint_path = tf . train . latest_checkpoint ( FLAGS . checkpoint_path ) else : checkpoint_path = FLAGS . checkpoint_path tf . logging . info ( ( 'Fine-tuning from %s' % checkpoint_path ) ) return slim . assign_from_checkpoint_fn ( checkpoint_path , variables_to_restore , ignore_missing_vars = FLAGS . ignore_missing_vars )
returns a function run by the chief worker to warm-start the training .