class_docstr: This class handles restoring the model at the beginning of a session.
class_docstr_tok: ["This","class","handles","restoring","the","model","at","the","beginning","of","a","session","."]
docstr: Loading checkpoint files as variable initialisations.
  
  :param _sender:
  :param _unused:
  :return:
docstr_tok: ["Loading","checkpoint","files","as","variable","initialisations",".",":","param","_sender",":",":","param","_unused",":",":","return",":"]
code: def restore_model(self, _sender, **_unused):
      """
      Loading checkpoint files as variable initialisations.
  
      :param _sender:
      :param _unused:
      :return:
      """
      checkpoint = "{}-{}".format(
          self.file_name_prefix, self.initial_iter
      )
      to_restore = None  # tf.train.Saver's default value, restoring all
  
      if self.vars_to_restore:
          # partially restore (updating `to_restore` list)
          tf.logging.info("Finding variables to restore...")
          import re
  
          # Determine which vars to
          # restore using regex matching
          var_regex = re.compile(self.vars_to_restore)
          to_restore, to_randomise = [], []
          for restorable in tf.global_variables():
              if var_regex.search(restorable.name):
                  to_restore.append(restorable)
              else:
                  to_randomise.append(restorable)
  
          if not to_restore:
              tf.logging.fatal(
                  "vars_to_restore specified: %s, but nothing matched.",
                  self.vars_to_restore,
              )
              assert (
                  to_restore
              ), "Nothing to restore (--vars_to_restore)"
  
          var_names = [  # getting first three item to print
              var_restore.name for var_restore in to_restore[:3]
          ]
          tf.logging.info(
              "Restoring %s out of %s variables from %s: \n%s, ...",
              len(to_restore),
              len(tf.global_variables()),
              checkpoint,
              ",\n".join(var_names),
          )
          # Initialize vars to randomize
          init_op = tf.variables_initializer(to_randomise)
          tf.get_default_session().run(init_op)
  
      try:
          saver = tf.train.Saver(
              var_list=to_restore, save_relative_paths=True
          )
          saver.restore(tf.get_default_session(), checkpoint)
      except tf.errors.NotFoundError:
          tf.logging.fatal(
              "checkpoint %s not found or variables to restore do not "
              "match the current application graph",
              checkpoint,
          )
          dir_name = os.path.dirname(checkpoint)
          if dir_name and not os.path.exists(dir_name):
              tf.logging.fatal(
                  "Model folder not found %s, please check"
                  "config parameter: model_dir",
                  dir_name,
              )
          raise
  
file_path: NiftyNet/niftynet/engine/handler_model.py
imports: import os
  import tensorflow
  from niftynet.engine.application_variables import global_vars_init_or_restore
  from niftynet.engine.signal import ITER_FINISHED, SESS_FINISHED, SESS_STARTED
  from niftynet.io.misc_io import touch_folder
label_desc: Use image node_id 3 for calling the ModelRestorer obj's underlying member method code with example usage: obj.restore_model(_sender) without return types