Tensorflow检查点模型被删除

Nit*_*tin 4 checkpoint tensorflow

我使用以下代码在每10个纪元后使用tensorflow检查点:

checkpoint_dir = os.path.abspath(os.path.join(out_dir, "checkpoints"))
checkpoint_prefix = os.path.join(checkpoint_dir, "model")
...
if current_step % checkpoint_every == 0:
    path = saver.save(sess, checkpoint_prefix, global_step=current_step)
    print("Saved model checkpoint to {}\n".format(path))
Run Code Online (Sandbox Code Playgroud)

问题是,随着新文件的生成,以前的5个模型文件会自动被删除.

小智 11

这是预期的行为,tf.train.Saver的文档说默认情况下会保留5个最新的检查点文件.要调整它,请将max_to_keep设置为所需的值.