如何控制张量流量估算器保存的检查点数量?

问题描述 投票:3回答:1

我注意到新的Estimator API会在训练期间自动保存检查点,并在训练中断时自动从上一个检查点重新启动。不幸的是,它似乎只保留了最后5个检查点。

您知道如何控制培训期间保留的检查点数量吗?

tensorflow tensorflow-estimator
1个回答
6
投票

Tensorflow tf.estimator.Estimatorconfig作为可选参数,可以是用于配置运行时设置的tf.estimator.RunConfig对象。您可以按如下方式实现此目的:

# Change maximum number checkpoints to 25
run_config = tf.estimator.RunConfig()
run_config = run_config.replace(keep_checkpoint_max=25)

# Build your estimator
estimator = tf.estimator.Estimator(model_fn,
                                   model_dir=job_dir,
                                   config=run_config,
                                   params=None)

config参数适用于扩展DNNClassifier的所有类别(DNNLinearCombinedClassifierLinearClassifierestimator.Estimator等)。

© www.soinside.com 2019 - 2024. All rights reserved.