我发现在 Tensorflow 中有不同的方法来保存/恢复模型和变量。这些方式包括:
在tensorflow的文档中,我发现了它们之间的一些区别:
tf.saved_model是tf.train.Saver 的薄包装
tf.train.Checkpoint支持即时执行,但tf.train.Saver不。tf.train.Checkpoint没有创建.meta文件,但仍然可以加载图形结构(这是一个大问题!它是怎么做到的?)
tf.train.Checkpoint 如何在没有 .meta 文件的情况下加载图表?或者更一般地说,tf.train.Saver 和 tf.train.Checkpoint 有什么区别?
请您参考如下方法:
根据 Tensorflow docs :
Checkpoint.saveandCheckpoint.restorewrite and read object-based checkpoints, in contrast totf.train.Saverwhich writes and reads variable.name based checkpoints. Object-based checkpointing saves a graph of dependencies between Python objects (Layers, Optimizers, Variables, etc.) with named edges, and this graph is used to match variables when restoring a checkpoint. It can be more robust to changes in the Python program, and helps to support restore-on-create for variables when executing eagerly. Prefertf.train.Checkpointovertf.train.Saverfor new code.
