Unverified Commit c8e09af4 authored by Tai-Wang's avatar Tai-Wang Committed by GitHub
Browse files

Fix potential undefined variables in PGD when computing loss for cases with...

Fix potential undefined variables in PGD when computing loss for cases with none positive predictions (#1157)
parent c19ce855
...@@ -777,12 +777,11 @@ class PGDHead(FCOSMono3DHead): ...@@ -777,12 +777,11 @@ class PGDHead(FCOSMono3DHead):
loss_dict['loss_dir'] = pos_dir_cls_preds.sum() loss_dict['loss_dir'] = pos_dir_cls_preds.sum()
if self.use_depth_classifier: if self.use_depth_classifier:
sig_alpha = torch.sigmoid(self.fuse_lambda) sig_alpha = torch.sigmoid(self.fuse_lambda)
loss_fuse_depth = \
sig_alpha * pos_bbox_preds[:, 2].sum() + \
(1 - sig_alpha) * pos_depth_cls_preds.sum()
if self.weight_dim != -1: if self.weight_dim != -1:
loss_fuse_depth *= torch.exp(-pos_weights[:, 0].sum()) loss_fuse_depth *= torch.exp(-pos_weights[:, 0].sum())
else:
loss_fuse_depth = \
sig_alpha * pos_bbox_preds[:, 2].sum() + \
(1 - sig_alpha) * pos_depth_cls_preds.sum()
loss_dict['loss_depth'] = loss_fuse_depth loss_dict['loss_depth'] = loss_fuse_depth
if self.pred_attrs: if self.pred_attrs:
loss_dict['loss_attr'] = pos_attr_preds.sum() loss_dict['loss_attr'] = pos_attr_preds.sum()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment