training error about background
Hi, @weiliu89. Thanks for you work. Recently, i have train SSD300 on traffic signs dataset. My labelmap_voc.prototxt has 44 items including "background" with label "0". But in training process, when it comes to "Testing net", it has error "F0804 15:47:44.315160 3383 bbox_util.cpp:781] Check failed: background_label_id != label (0 vs. 0) Found background label in the detection results.". Can you help me? Thank you.
Have you specified this?
@weiliu89 Yes, background_label_id=0 in ssd_pascal.py. And my labelmap_voc.prototxt is like this: item { name: "none_of_the_above" label: 0 display_name: "background" } item { name: "speed_limit_30" label: 1 display_name: "speed_limit_30" } item { name: "speed_limit_50" label: 2 display_name: "speed_limit_50" }
Hi, @weiliu89. I solved the problem by "make clean" and "make/make pycaffe" again. But in the training process, i met another problem. The training log is like this: I0806 12:12:22.577077 23202 solver.cpp:231] Iteration 45290, loss = nan I0806 12:12:22.577157 23202 solver.cpp:247] Train net output #0: mbox_loss = nan (* 1 = nan loss) And when testing net, the log is like this: I0805 16:29:54.203732 23202 detection_output_layer.cu:123] Couldn't find any detections ... What caused that problem, how can i slove that? Thank you.
@weiliu89 My image format is .ppm and my annotation format is xml.
How often does this happen?
@weiliu89 Every iteration in train net and each time in test net.
@lxd7714059 I have encoutered the same problem as you? Have you solved it? Would you please tell me how to solve it? Thanks a lot!
@Li1991 I don't know exactly why that happen. I usually meet the problem after several iteration. When I met the problem, I just make everything clean, then run it again. You can try it or you can try to decrease you learning rate.
@lxd7714059 If you find out why it goes to nan (occasionally I guess), please let me know. I think some of my colleagues have encountered the issue occasionally. I haven't met such issue personally though.
@weiliu89 I tried to found the reason in caffe. Many people meet the problem, the reason might be "Bad data scaling and/or bad learning rates often cause training to diverge, producing NaN values." as #1349 said. The author makes training crash when it meets nan. Maybe we can solve the problem by decreasing learning rate.
Ok. If it becomes nan in the beginning (e.g. first few hundred iterations), then lowering learning rate can definitely help. But if the loss is decreasing normally in the beginning, but suddenly it goes to nan after several thousands , then it is a problem (maybe a bug somewhere). I assume you were experiencing the later problem?
@weiliu89 Yes, i experienced the later problem. The loss is decreasing normally in the beginning, but before it goes to nan, the loss can suddenly be very large (one ~ two magnitude).
@lxd7714059 It might due to a bug and hopefully has been fixed in e4cde71 What is the batch size you use during training? If it is small, then it is likely that there is no ground truth in a batch of images, and thus cannot find any match, which makes the loss goes up very high suddenly. Or if your dataset doesn't have very sparse bounding boxes. I usually used 8 VOC/COCO/ILSVRC images in a batch, and the possibility of having such bug is very very small.
You could pull the latest code and try again...
I meet the same problem about the background issue when training a model on KITTI dataset.
I0913 09:59:00.460297 236632 solver.cpp:337] Iteration 10000, Testing net (#0) I0913 09:59:00.500334 236632 net.cpp:684] Ignoring source layer mbox_loss F0913 09:59:00.675498 236632 bbox_util.cpp:781] Check failed: background_label_id != label (0 vs. 0) Found background label in the detection results.
I am using the Windows environment so the SSD was complied by VS2013. Everything goes well before this problem. The test & training lmdb files were generated successfully without any error or warning. I am so confused about that. I have modified labelmap.prototxt and set the background_label_id = 0 in the python script.
item { name: "none_of_the_above" label: 0 display_name: "background" } item { name: "Car" label: 1 display_name: "Car" }
# MultiBoxLoss parameters. num_classes = 2 share_location = True background_label_id=0 train_on_diff_gt = True
I made a silly mistake. I have fixed it. : )
@wgting96 Hello~I have similar mistake,how could you solve this?
@WillyPKU When I transplanted SSD to Windows platform, I edited some codes and made a mistake. The original codes can work well for me. Maybe you can check the training configuration, like labelmap.prototxt ?