code: def begin(self):
      
      variables_to_restore = tf.contrib.framework.get_variables_to_restore(
          include=self._include, exclude=self._exclude)
      # remove new_model_scope from variable name prefix
      assignment_map = {variable.name[len(self._new_model_scope):]: variable
                        for variable in variables_to_restore
                        if variable.name.startswith(self._new_model_scope)}
      # remove :0 from variable name suffix
      assignment_map = {name.split(":")[0]: variable
                        for name, variable in six.iteritems(assignment_map)
                        if name.startswith(self._old_model_scope)}
      self._assignment_map = assignment_map
  
      tf.logging.info("restoring %d variables from checkpoint %s"%(
          len(assignment_map), self._checkpoint_path))
      tf.train.init_from_checkpoint(self._checkpoint_path, self._assignment_map)
docs: Load variables from checkpoint.
  
      New model variables have the following name foramt:
      new_model_scope/old_model_scope/xxx/xxx:0 To find the map of
      name to variable, need to strip the new_model_scope and then
      match the old_model_scope and remove the suffix :0.