From f892f4d991ea40f7d48546ceac39bd46e27e5cb4 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 14 Jun 2019 13:06:13 +0800 Subject: [PATCH] add yolov3 label_smooth faq (#2407) * add yolov3 label_smooth faq * refine en --- PaddleCV/yolov3/README.md | 3 +++ PaddleCV/yolov3/README_en.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/PaddleCV/yolov3/README.md b/PaddleCV/yolov3/README.md index 3e23f80f..1817b615 100644 --- a/PaddleCV/yolov3/README.md +++ b/PaddleCV/yolov3/README.md @@ -297,6 +297,9 @@ if cfg.pretrain: **Q:** 我训练YOLOv3速度比较慢,要怎么提速? **A:** YOLOv3的数据增强比较复杂,速度比较慢,可通过在[reader.py](./reader.py#L284)中增加数据读取的进程数来提速。若用户是进行fine-tune,也可将`--no_mixup_iter`设置大于`--max_iter`的值来禁用mixup提升速度。 +**Q:** 我使用YOLOv3训练两个类别的数据集,训练`loss=nan`或推断结果不符合预期,这是为什么? +**A:** `--label_smooth`参数会把所有正例的目标值设置为`1-1/class_num`,负例的目标值设为`1/class_num`,当`class_num`较小时,这个操作影响过大,可能会出现`loss=nan`或者训练结果错误,类别数较小时建议设置`--label_smooth=False`。若使用Paddle Fluid v1.5及以上版本,我们在C++代码中对这种情况作了保护,设置`--label_smooth=True`也不会出现这些问题。 + ## 参考文献 - [You Only Look Once: Unified, Real-Time Object Detection](https://arxiv.org/abs/1506.02640v5), Joseph Redmon, Santosh Divvala, Ross Girshick, Ali Farhadi. diff --git a/PaddleCV/yolov3/README_en.md b/PaddleCV/yolov3/README_en.md index a95f1ae2..c8369192 100644 --- a/PaddleCV/yolov3/README_en.md +++ b/PaddleCV/yolov3/README_en.md @@ -297,6 +297,9 @@ if cfg.pretrain: **Q:** YOLOv3 training in my machine is very slow, how can I speed it up? **A:** Image augmentation is very complicated and time consuming in YOLOv3, you can set more workers for reader in [reader.py](./reader.py#L284) for speeding up. If you are fine-tuning, you can also set `--no_mixup_iter` greater than `--max_iter` to disable image mixup. +**Q:** YOLOv3 training with 2 categories dataset got `loss=nan` or wrong prediction, why? +**A:** Settting `--label_smooth` will smooth target value of positive sample to `1-1/class_num` and target of negative sample to `1/class_num`, if `class_num` is very small, label smooth will incur excessive influence and may cause `loss=nan` or wrong prediction, it is recommend to set `--label_smooth=False` while category number is small. If you are using Paddle Fluid v1.5 and above, this situation is protected in C++ code, setting `--label_smooth=True` will no longer incur such error. + ## Reference - [You Only Look Once: Unified, Real-Time Object Detection](https://arxiv.org/abs/1506.02640v5), Joseph Redmon, Santosh Divvala, Ross Girshick, Ali Farhadi. -- GitLab