【问题标题】:Queries regarding checkpoints of Object Detection API关于 Object Detection API 检查点的查询
【发布时间】:2018-08-21 20:23:11
【问题描述】:

我对 Tensorflow 对象检测 API 有一些疑问。

  1. 训练时,仅存储前 5 个检查点。我想存储更多,比如前 10 个检查点。如何才能做到这一点? (我觉得应该是object_detection/protostrain.proto的参数之一。)

  2. 默认情况下,检查点每 10 分钟(600 秒)存储一次。要改变这个频率,我认为是这两个参数之一必须改变,请确认是哪一个:

    来自learning.py in /home/user/tensorflow-gpu/lib/python3.5/site-packages/tensorflow/contrib/slim/python/slim

    save_summaries_secs=600

    save_interval_secs=600

  3. 在训练我的模型 (ssd_mobilenet_v2_coco_2018_03_29) 时,我还同时运行评估。 eval 图中表示的最新检查点始终落后于保存在 object_detection/training 文件夹中的最新检查点。例如,在下面的例子中,图上显示的最新检查点是 29.437k,而模型已经训练到检查点 32.891k(并保存在 training 文件夹中)。这种滞后(20 分钟滞后)的原因是什么?为什么一步(10 分钟)不足以对训练好的模型进行评估?

【问题讨论】:

  • 这篇文章应该可以工作,我相信可以改变 keep_checkpoint_every_n_hours
  • 第二点,这个解决方案对我有用:github.com/tensorflow/models/issues/5139#issuecomment-418963839。例如,在每 1000 步后保存模型,将行(在链接中的解决方案中提到)从:“config = tf.estimator.RunConfig(model_dir=FLAGS.model_dir)”更改为:“config = tf.estimator .RunConfig(model_dir=FLAGS.model_dir, save_checkpoints_steps = 1000)"

标签: python tensorflow image-processing object-detection object-detection-api


【解决方案1】:

这适用于想要配置支持 TensorFlow 2 的更新对象检测 API 的任何人

  1. 要保存前 10 个检查点,请打开 model_lib.py 并将关键字参数 max_to_keep=10 传递给每个 tf.train.Saver 函数
  2. 要将频率从 600 秒更改为 3600 秒(1 小时), 打开 model_main.py 并在 main 函数中找到包含 tf.estimator.RunConfig 的行。
    将关键字参数 save_checkpoints_secs=3600 传递给 tf.estimator.RunConfig 上课。

这是在model_main.py中配置检查点保存频率后的代码sn-p:

def main(unused_argv):
      flags.mark_flag_as_required('model_dir')   
      flags.mark_flag_as_required('pipeline_config_path')   
      config = tf.estimator.RunConfig(model_dir=FLAGS.model_dir, save_checkpoints_secs=3600)

请注意有一个参数keep_checkpoint_max tf.estimator.RunConfig 类,但设置它不会影响我保存的检查点的数量。

【讨论】:

    【解决方案2】:

    我相信这里的这篇文章应该可以改变 keep_checkpoint_every_n_hours max_to_keep

    How to store best models checkpoints, not only newest 5, in Tensorflow Object Detection API?

    你也可以参考官方文档 https://www.tensorflow.org/api_docs/python/tf/train/Saver

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 2018-01-28
      相关资源
      最近更新 更多