princeton-vl / CornerNet

BSD 3-Clause "New" or "Revised" License
2.36k stars 475 forks source link

bug in ae_loss #179

Closed zhangming8 closed 3 years ago

zhangming8 commented 3 years ago

Hi, thanks for you great work. When you calculate pull loss in ae_loss, https://github.com/princeton-vl/CornerNet/blob/master/models/py_utils/kp_utils.py#L188 and https://github.com/princeton-vl/CornerNet/blob/master/models/py_utils/kp_utils.py#L190

I think it should be tag0[mask>0].sum(), tag1[mask>0].sum() or (tag0xmask).sum(), (tag1xmask).sum() (they are same), but you are using tag0[mask] and tag1[mask] they are different with above.

zhangming8 commented 3 years ago

The type of mask is uint8 so anything that is non-zero would be considered as True and can be used as a boolean mask. Here is a small code snippet to demonstrate this behavior:

import torch a = torch.arange(10) b = torch.zeros((10, ), dtype=torch.uint8) b[2] = 1 a[b]

:1: UserWarning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead. (Triggered internally at /pytorch/aten/src/ATen/native/IndexingUtils.h:30.) tensor([2]) b[2] = 2 a[b] tensor([2])

This became a deprecated behavior after PyTorch had officially introduced boolean type. But this code is no longer maintained so I didn’t update it for the newer version of PyTorch. If you have more questions, please feel free to let me know.

--by Hei Law