Open yjh0410 opened 2 years ago
@chensnathan
I think the following passage may be the main cause of the NAN problem:
normalized_cls_score = cls_score + objectness - torch.log(
There is an exp operation in this code, and clip is used to clip it to avoid explosion, but this still has hidden dangers, that is, before clipping, the exp may have exploded and overflowed, so the clip is useless at this time.
So, I changed to clip first and then exp,:
normalized_cls_pred = cls_pred + obj_pred - torch.log(
torch.clamp(cls_pred, max=DEFAULT_EXP_CLAMP).exp() + torch.clamp(obj_pred, max=DEFAULT_EXP_CLAMP).exp())
where DEFAULT_EXP_CLAMP = log(INF).
After above modification, NAN problem no longer encountered.
Thanks for your suggestion, we will check it. If so, we will update our code with it.
@chensnathan
I think the following passage may be the main cause of the NAN problem:
normalized_cls_score = cls_score + objectness - torch.log(
There is an exp operation in this code, and clip is used to clip it to avoid explosion, but this still has hidden dangers, that is, before clipping, the exp may have exploded and overflowed, so the clip is useless at this time.
So, I changed to clip first and then exp,:
normalized_cls_pred = cls_pred + obj_pred - torch.log(
where DEFAULT_EXP_CLAMP = log(INF).
After above modification, NAN problem no longer encountered.