def save(self):
     cur_dir = self.get_cur_epoch_dir()
     epoch_name = utils.grep_epoch_name(cur_dir)
     model_builder = tf.saved_model.builder.SavedModelBuilder(cur_dir +
                                                              "/model")
     model_builder.add_meta_graph_and_variables(self.sess, [epoch_name])
     model_builder.save()
    def __init__(self, model_dir):
        if "epoch" not in model_dir:
            model_dir = utils.get_latest_epoch(model_dir)

        epoch_name = utils.grep_epoch_name(model_dir)
        self.sess = tf.Session(graph=tf.Graph())
        tf.saved_model.loader.load(self.sess, [epoch_name],
                                   model_dir + "/model")
Exemple #3
0
    def __init__(self, model_dir):
        if "epoch" not in model_dir:  # 如果model_dir中不包含'epoch'
            model_dir = utils.get_latest_epoch(
                model_dir)  # 就将model_dir重新赋值为最近的一个epoch的路径

        epoch_name = utils.grep_epoch_name(model_dir)  # 得到epoch_*(*是数字)
        self.sess = tf.Session(graph=tf.Graph())
        tf.saved_model.loader.load(  # 读取模型参数
            self.sess, [epoch_name], model_dir + "\\model")
Exemple #4
0
 def restore(self, epoch_dir):
     epoch_name = utils.grep_epoch_name(epoch_dir)
     tf.saved_model.loader.load(
         self.sess, [epoch_name], epoch_dir + "/model")