如何在 Tensorflow 对象检测 API 中存储最佳模型检查点,不仅是最新的 5 个? [英] How to store best models checkpoints, not only newest 5, in Tensorflow Object Detection API?

查看:38
本文介绍了如何在 Tensorflow 对象检测 API 中存储最佳模型检查点,不仅是最新的 5 个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 WIDER FACE 数据集上训练 MobileNet,但遇到了无法解决的问题.TF Object Detection API 仅在 train 目录中存储最后 5 个检查点,但我想做的是保存相对于 mAP 指标的最佳模型(或至少在 train 目录删除前).例如,今天我在第二天晚上的训练后查看了 Tensorboard,我发现隔夜模型过度拟合,我无法恢复最佳检查点,因为它已经被删除了.

I'm training MobileNet on WIDER FACE dataset and I encountered problem I couldn't solve. TF Object Detection API stores only last 5 checkpoints in train dir, but what I would like to do, is to save best models relative to mAP metric (or at least leave many more models in train dir before deletion). For example, today I've looked at Tensorboard after next night of training and I see that overnight model has over-fitted and I can't restore best checkpoint, because it was deleted already.

我只是使用 Tensorflow 对象检测 API,它由默认将最后 5 个检查点保存在我指向的火车目录中.我寻找一些配置参数或任何会改变这种行为的东西.

I just use Tensorflow Object Detection API, it by default saves last 5 checkpoints in train dir which I point. I look for some configuration parameter or anything that will change this behavior.

有没有人在代码/配置参数中有一些修复来设置/解决方法?似乎我遗漏了一些东西,很明显,实际上重要的是最好的模型,而不是最新的模型(可能会过拟合).

Has anyone have some fix in code/config param to set/workaround for that? It seems like I'm missing something, it should be obvious that what's in fact important is the best model, not the newest one (which can overfit).

谢谢!

推荐答案

您可以修改(在您的 fork 中进行硬编码或打开拉取请求并将选项添加到 protos)传递给 tf.train.Saver 在:

You can modify (hardcoding in your fork or opening a pull request and adding the options to protos) the arguments passed to tf.train.Saver in:

https://github.com/tensorflow/models/blob/master/research/object_detection/legacy/trainer.py#L376-L377

您可能想要设置:

  • max_to_keep:要保留的最近检查点的最大数量.默认为 5.
  • keep_checkpoint_every_n_hours:保持检查点的频率.默认为 10,000 小时.

这篇关于如何在 Tensorflow 对象检测 API 中存储最佳模型检查点,不仅是最新的 5 个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆