(use_tpu, init_checkpoint)
return scaffold_fn
load variables from initial checkpoints.

  Args:
    use_tpu: bool whether to use tpu.
    init_checkpoint: path of checkpoint containing variables to be initialized.

  Returns:
    scaffold_fn: The scaffold_fn used by tpu estimator spec. If use_tpu=False,
    this is set to None.
load variables from initial checkpoints.
load variables from initial checkpoints .
def _load_vars_from_checkpoint(use_tpu, init_checkpoint):
  """load variables from initial checkpoints.

  Args:
    use_tpu: bool whether to use tpu.
    init_checkpoint: path of checkpoint containing variables to be initialized.

  Returns:
    scaffold_fn: The scaffold_fn used by tpu estimator spec. If use_tpu=False,
    this is set to None.
  """
  if not init_checkpoint:
    return None
  tvars = tf.trainable_variables()
  (assignment_map,
   initialized_variable_names) = get_assignment_map_from_checkpoint(
       tvars, init_checkpoint)
  if not initialized_variable_names:
    raise ValueError("No matching variables in init_checkpoint. "
                     "Double check the naming in both models.")
  scaffold_fn = None
  if use_tpu:

    def tpu_scaffold():
      tf.train.init_from_checkpoint(init_checkpoint, assignment_map)
      return tf.train.Scaffold()

    scaffold_fn = tpu_scaffold
  else:
    tf.train.init_from_checkpoint(init_checkpoint, assignment_map)

  logging.info("**** Trainable Variables ****")
  for var in tvars:
    init_string = ""
    if var.name in initialized_variable_names:
      init_string = ", *INIT_FROM_CKPT*"
    logging.info("  name = %s, shape = %s%s", var.name, var.shape, init_string)
  return scaffold_fn
def _load_vars_from_checkpoint ( use_tpu , init_checkpoint ) : if not init_checkpoint : return None tvars = tf . trainable_variables ( ) ( assignment_map , initialized_variable_names ) = get_assignment_map_from_checkpoint ( tvars , init_checkpoint ) if not initialized_variable_names : raise ValueError ( "No matching variables in init_checkpoint. " "Double check the naming in both models." ) scaffold_fn = None if use_tpu : def tpu_scaffold ( ) : tf . train . init_from_checkpoint ( init_checkpoint , assignment_map ) return tf . train . Scaffold ( ) scaffold_fn = tpu_scaffold else : tf . train . init_from_checkpoint ( init_checkpoint , assignment_map ) logging . info ( "**** Trainable Variables ****" ) for var in tvars : init_string = "" if var . name in initialized_variable_names : init_string = ", *INIT_FROM_CKPT*" logging . info ( "  name = %s, shape = %s%s" , var . name , var . shape , init_string ) return scaffold_fn