TF2 对象检测 API:model_main_tf2.py - 验证丢失?

2024-04-11

过去两个月我一直在尝试训练一个对象检测模型,并最终通过以下方法成功了tutorial https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/.

这是我的colab https://colab.research.google.com/drive/1Dn3bgYkialkPXImM1XWaYqjgVNTGI9Fn?usp=sharing其中包含我所有的工作。

问题是,训练损失已显示出来,并且平均在下降,但验证损失却没有。

In the pipeline.config文件中,我确实输入了评估 TFRecord 文件(我假设它是验证数据输入),如下所示:

评估配置{

指标集:“coco_detection_metrics”

use_moving_averages: false

}

eval_input_reader {

label_map_path: "注释/label_map.pbtxt"

随机播放:假

纪元数:1

tf_record_input_reader {

input_path: "注释/test.record"

}

}

我通读了model_main_tf2.py https://github.com/tensorflow/models/blob/master/research/object_detection/model_main_tf2.py,它似乎在训练时不进行评估,而仅在提到 checkpoint_dir 时进行评估。

因此,我只能监控训练集上的损失,而不能监控验证集上的损失。

结果,我不知道过度拟合或拟合不足。

你们中有人成功地使用 model_main_tf2.py 来查看验证损失吗?

另外,如果能看到训练后的 mAP 分数那就太好了。

我知道 keras 训练允许在张量板上看到所有这些东西,但 OD API 似乎要困难得多。

感谢您抽出宝贵的时间,如果您仍然对某些事情感到困惑,请告诉我。


你必须打开另一个航站楼并运行这个命令

python model_main_tf2.py \
   --model_dir=models/my_ssd_resnet50_v1_fpn \
   --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config \
   --checkpoint_dir=models/my_ssd_resnet50_v1_fpn

This API教程 https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html#evaluating-the-model-optional关于该主题尚不清楚。我有完全相同的问题。

事实证明,评估过程不包含在训练循环中,您必须在parallel.

它会等待并说waiting for new checkpoint,这意味着您将开始以下培训:

python model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config # note that the checkpoint_dir argument is not there

它将每隔一次运行评估eval_interval_secs在你的eval_config.

根据文档,评估指标将存储在 eval_0 目录中的检查点旁边,然后您可以在张量板上绘制该目录。

我确实同意这有点难以理解,因为它在文档中不是很清楚,而且也不是很方便,因为我必须分配另一个 GPU 来进行评估以避免 CUDA 内存不足问题。

祝你今天过得愉快

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TF2 对象检测 API:model_main_tf2.py - 验证丢失? 的相关文章

随机推荐