Example #1
0
    def save_checkpoint(self, path):
        setup_directory(path)

        check_point_path = path_join(path, 'check_point', 'instance.ckpt')
        setup_file(check_point_path)
        saver = tf.train.Saver(self.main_graph_var_list +
                               self.misc_ops_var_list)
        saver.save(self.sess, check_point_path)
Example #2
0
    def save_meta(self, path):
        setup_directory(path)

        self.metadata.save(path_join(path, 'meta.pkl'))
        self.metadata.save(path_join(path, 'meta.json'))

        self.params_path = path_join(path, 'params.pkl')
        self._save_params(self.params_path)
Example #3
0
 def __init__(self, logdir, name, device='/cpu:0', epoch=0, verbose=0):
     super().__init__(verbose)
     self.logdir = logdir
     setup_directory(self.logdir)
     self.name = name
     self.device = device
     self.writer = None
     self.epoch = epoch
     self.sess = None
     self.is_build = False
     self.x_shape = None
Example #4
0
    def __init__(self, path, max_best=True, name='BestSave', log=print):
        self.path = path
        self.max_best = max_best
        self.name = name
        self.log = log

        if self.max_best:
            self.best_metric = -np.Inf
        else:
            self.best_metric = np.Inf

        setup_directory(self.path)
Example #5
0
    def __init__(self, path, k=5, max_best=True, save_model=True, name='top_k_save', log=print):
        self.path = path
        self.k = k
        self.max_best = max_best
        self.save_model = save_model
        self.name = name
        self.log = log

        self.top_k_json_path = path_join(self.path, 'top_k.json')
        if os.path.exists(self.top_k_json_path):
            self.top_k = load_json(self.top_k_json_path)
        else:
            if self.max_best:
                self.top_k = [np.Inf] + [-np.Inf for _ in range(self.k)]
            else:
                self.top_k = [-np.Inf] + [np.Inf for _ in range(self.k)]

        if self.save_model:
            for i in range(1, self.k + 1):
                setup_directory(path_join(self.path, f'top_{i}'))