tensorflow相比于keras的保存要麻烦许多。
保存:
with tf.Session() as sess:
saver = tf.train.Saver(max_to_keep=20)
saver.save(sess, os.path.join(train_output_dir, "model"), global_step=step)
实际保存的是sess中的值,得到
读取:(个人感觉非常啰嗦)
with tf.Session() as sess:
model = tf.train.import_meta_graph(trainResultPath)
model.restore(sess, trainResultPath2)
trainResultPath:meta的文件的位置,例如:
trainResultPath = "F:/train_out/model-7999.meta"
trainResultPath:为三个文件的文件夹目录,例如:
trainResultPath2 = "F:/train_out/model-7999"
比较坑的是,一个是文件的地址,一个是文件夹的地址,而且没有例子,晕。