tensorflow - 如何控制 tensorflow 估计器保留的检查点数量?

标签 tensorflow tensorflow-estimator

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

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

最佳答案

Tensorflow tf.estimator.Estimator需要 config作为可选参数,可以是 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 等) .

关于tensorflow - 如何控制 tensorflow 估计器保留的检查点数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48028262/

相关文章:

python - 模糊图像的特定部分

python - Keras 数字数据集 : expected conv2d_input to have 4 dimensions, 中出现错误,但获得形状为 (60000, 28, 28) 的数组

python - 制作自定义 Keras 层时无法使用未知的输入 Dims(批量大小)

python - Tensorflow 2 Keras 嵌套模型子类化 - 总参数为零

python - 在预训练的 BERT 上进行微调后如何导出/保存文本分类器

python - TensorFlow v2 : Replacement for tf. contrib.predictor.from_saved_model

python - 如何从 TensorFlow 中的 SparseTensor 中选择一行?

python - 使用 tf.estimator.Estimator 框架进行迁移学习

tensorflow - 如何在 Tensorflow Estimator 的每个全局步骤中获得训练损失和评估损失?

python - 如何获得 tf.estimator.predict() 准确性?