def __init__(self, model_dir, initial_iter=0, is_training_action=True, **_unused): self.initial_iter = initial_iter self.file_name_prefix = make_model_name(model_dir) # randomly initialise or restoring model if is_training_action and initial_iter == 0: SESS_STARTED.connect(self.rand_init_model) else: SESS_STARTED.connect(self.restore_model)
def __init__(self, model_dir, save_every_n=0, max_checkpoints=1, is_training_action=True, **_unused): self.save_every_n = save_every_n self.max_checkpoints = max_checkpoints self.file_name_prefix = make_model_name(model_dir) self.saver = None # initialise the saver after the graph finalised SESS_STARTED.connect(self.init_saver) # save the training model at a positive frequency if self.save_every_n > 0: ITER_FINISHED.connect(self.save_model_interval) # always save the final training model before exiting if is_training_action: SESS_FINISHED.connect(self.save_model)