Closed qfwysw closed 3 years ago
Please follow the issue template for 'Reimplementation Questions' to redescribe your question.
Thanks for your solution, it solves the problem. However, there is another question, we know gt_labels of Kitti for donotcare is -1. It cause the new error in target = F.one_hot(target, num_classes=num_classes + 1).
Errr, so first of all I want to ask, can you train the code without any modifications?
I don't know why you want to call the loss function by yourself instead of calling self.cls_loss
? Because I think self.cls_loss
is also FocalLoss which is exactly what you want?
Emmmm, the truth is that I want to learn the code of pointpillar but the code jumps too many times. So I'm trying to pull the code out of mmcv. It's hard for me to write the focal_loss by cuda c, so I just want use the py_focal_loss to replace it.
Of course the code can run correctly without any modification.
OK I understand, that's no problem. As for your question about -1 label, if you look into the cuda coda of focal loss here, they just ignore the -1 label by setting loss=0
. And it seems no such operation in py_sigmoid_focal_loss
.
In my opinion, this is indeed a bug. But as py_sigmoid_focal_loss
is designed for debug, we don't expect it to work perfectly. I think focal loss is easy to understand and you can just use the original implementation? Or you can manually filter out -1 labels before calling py_sigmoid_focal_loss
?
Feel free to re-open this issue should you have any further questions :)
Checklist
Describe the issue I try to understand the try to understand the theory of the focal_loss by reading the py_sigmoid_focal_loss. After reading that, I run the code below, but get the error. loss_cls = self.loss_cls(cls_score, labels, label_weights, avg_factor=num_total_samples) ll = py_sigmoid_focal_loss(cls_score, labels, label_weights, avg_factor=num_total_samples) Reproduction
What command or script did you run?
What config dir you run?
Did you make any modifications on the code or config? Did you understand what you have modified?
What dataset did you use?
Environment
Please run
python mmdet3d/utils/collect_env.py
to collect necessary environment infomation and paste it here. fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). sys.platform: linux Python: 3.7.10 (default, Feb 26 2021, 18:47:35) [GCC 7.3.0] CUDA available: True GPU 0,1: GeForce RTX 3090 CUDA_HOME: /usr/local/cuda-11.2 NVCC: Build cuda_11.2.r11.2/compiler.29558016_0 GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 1.7.1+cu110 PyTorch compiling details: PyTorch built with:TorchVision: 0.8.2+cu110 OpenCV: 4.5.2 MMCV: 1.2.7 MMCV Compiler: GCC 7.5 MMCV CUDA Compiler: 11.2 MMDetection: 2.10.0 MMDetection3D: 0.13.0+
$PATH
,$LD_LIBRARY_PATH
,$PYTHONPATH
, etc.)Results
If applicable, paste the related results here, e.g., what you expect and what you get.