Пример #1
0
 def initialize(self, checkpoint_path=None):
     """Initialize from scratch or restore and keep restorer around."""
     init_op = tf.variables_initializer(self.get_init_variables())
     self.session.run(init_op)
     if checkpoint_path is not None:
         restorer = RestoreTFModelHook(
             variables=self.get_restore_variables(),
             checkpoint_path=ProjectManager.checkpoints,
             global_step_setter=self.set_global_step,
         )
         with self.session.as_default():
             restorer(checkpoint_path)
 def initialize(self, checkpoint_path=None):
     """Overwrite default to make lazy"""
     init_op = tf.variables_initializer(self.get_init_variables())
     self.session.run(init_op)
     if checkpoint_path is not None:
         self.set_global_step(
             RestoreTFModelHook.parse_global_step(checkpoint_path))
         init_assign_op, init_feed_dict = slim.assign_from_checkpoint(
             checkpoint_path,
             self.get_restore_variables(),
             ignore_missing_vars=True)
         self.session.run(init_assign_op, feed_dict=init_feed_dict)
         self.logger.info("Lazily restored from {}".format(checkpoint_path))
Пример #3
0
 def initialize(self, checkpoint_path=None):
     self.restore_variables = self.model.variables
     # wait for new checkpoint and restore
     if checkpoint_path:
         restorer = RestoreCurrentCheckpointHook(
             variables=self.restore_variables,
             checkpoint_path=checkpoint_path,
             global_step_setter=self.set_global_step,
         )
         self.hooks += [restorer]
     else:
         restorer = RestoreTFModelHook(
             variables=self.restore_variables,
             checkpoint_path=ProjectManager.checkpoints,
             global_step_setter=self.set_global_step,
         )
         waiter = WaitForCheckpointHook(
             checkpoint_root=ProjectManager.checkpoints,
             callback=restorer,
             eval_all=self.config.get("eval_all", False),
         )
         self.hooks += [waiter]