未验证 提交 a82f75be 编写于 作者: K Kaipeng Deng 提交者: GitHub

refix point_rcnn elementwise compatible. (#4053)

* refix point_rcnn elementwise compatible.

* remove axis=0 in get_reg_loss
上级 0bc89298
...@@ -191,8 +191,7 @@ def get_reg_loss(pred_reg, reg_label, fg_mask, point_num, loc_scope, ...@@ -191,8 +191,7 @@ def get_reg_loss(pred_reg, reg_label, fg_mask, point_num, loc_scope,
size_res_norm = fluid.layers.reshape(size_res_norm, shape=[-1, 1], inplace=True) size_res_norm = fluid.layers.reshape(size_res_norm, shape=[-1, 1], inplace=True)
size_loss = fluid.layers.smooth_l1(size_res_norm, size_res_norm_label) size_loss = fluid.layers.smooth_l1(size_res_norm, size_res_norm_label)
size_loss = fluid.layers.reshape(size_loss, shape=[-1, 3]) size_loss = fluid.layers.reshape(size_loss, shape=[-1, 3])
size_loss = fluid.layers.elementwise_mul(size_loss, fg_mask, axis=0) size_loss = fluid.layers.reduce_mean(size_loss * fg_mask) * fg_scale
size_loss = fluid.layers.reduce_mean(size_loss) * fg_scale
# Total regression loss # Total regression loss
reg_loss_dict['loss_loc'] = loc_loss reg_loss_dict['loss_loc'] = loc_loss
......
...@@ -276,14 +276,14 @@ class RCNN(object): ...@@ -276,14 +276,14 @@ class RCNN(object):
# RCNN regression loss # RCNN regression loss
reg_out = self.reg_out reg_out = self.reg_out
fg_mask = fluid.layers.cast(reg_valid_mask > 0, dtype=reg_out.dtype) fg_mask = fluid.layers.cast(reg_valid_mask > 0, dtype=reg_out.dtype)
fg_mask = fluid.layers.unsqueeze(fg_mask, axes=[1])
fg_mask.stop_gradient = True fg_mask.stop_gradient = True
gt_boxes3d_ct = fluid.layers.reshape(gt_boxes3d_ct, [-1,7]) gt_boxes3d_ct = fluid.layers.reshape(gt_boxes3d_ct, [-1,7])
all_anchor_size = roi_size all_anchor_size = roi_size
anchor_size = all_anchor_size[fg_mask] if self.cfg.RCNN.SIZE_RES_ON_ROI else self.cfg.CLS_MEAN_SIZE[0] anchor_size = all_anchor_size[fg_mask] if self.cfg.RCNN.SIZE_RES_ON_ROI else self.cfg.CLS_MEAN_SIZE[0]
masked_reg_out = fluid.layers.elementwise_mul(reg_out, fg_mask, axis=0)
loc_loss, angle_loss, size_loss, loss_dict = get_reg_loss( loc_loss, angle_loss, size_loss, loss_dict = get_reg_loss(
masked_reg_out, reg_out * fg_mask,
gt_boxes3d_ct, gt_boxes3d_ct,
fg_mask, fg_mask,
point_num=float(self.batch_size*64), point_num=float(self.batch_size*64),
......
...@@ -149,10 +149,10 @@ class RPN(object): ...@@ -149,10 +149,10 @@ class RPN(object):
rpn_reg = fluid.layers.reshape(rpn_reg, [-1, rpn_reg.shape[-1]]) rpn_reg = fluid.layers.reshape(rpn_reg, [-1, rpn_reg.shape[-1]])
reg_label = fluid.layers.reshape(rpn_reg_label, [-1, rpn_reg_label.shape[-1]]) reg_label = fluid.layers.reshape(rpn_reg_label, [-1, rpn_reg_label.shape[-1]])
fg_mask = fluid.layers.cast(cls_label_flat > 0, dtype=rpn_reg.dtype) fg_mask = fluid.layers.cast(cls_label_flat > 0, dtype=rpn_reg.dtype)
fg_mask = fluid.layers.unsqueeze(fg_mask, axes=[1])
fg_mask.stop_gradient = True fg_mask.stop_gradient = True
masked_rpn_reg = fluid.layers.elementwise_mul(rpn_reg, fg_mask, axis=0)
loc_loss, angle_loss, size_loss, loss_dict = get_reg_loss( loc_loss, angle_loss, size_loss, loss_dict = get_reg_loss(
masked_rpn_reg, rpn_reg * fg_mask,
reg_label, reg_label,
fg_mask, fg_mask,
float(self.batch_size * self.cfg.RPN.NUM_POINTS), float(self.batch_size * self.cfg.RPN.NUM_POINTS),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册