Closed YongtaoGe closed 5 years ago
@yongtaoge No, we do not normalize it. I suggest that you make use of L1
loss instead of IOULoss
in the code and compute the loss in a log scale. It should prevent the loss from diverging. Thank you very much!
@tianzhi0549 Thanks!
@tianzhi0549 Does it mean L1_loss(reg_scale)? reg_scale = log(reg_pre - reg_target), reg_pre = exp(x1box_conv_output) And the reg_target((l,r,t,b*) is not normalized.
@heiyuxiaokai No. It means torch.abs(log(reg_target) - log(reg_pred)).mean()
.
@tianzhi0549 I know, thanks.
@tianzhi0549 In iou_loss, the loss weight is centerness_target. If I ues L1 loss, should I use centerness_target as loss weight?
Yes.
@tianzhi0549 I'm trying fcos in mxnet. There are some questions about details. The reg_pred is (N, 4, hw). The centerness_target is (N, hw) l1 = abs(log1p(reg_target) - log1p(reg_pred)) (N, 4, hw) l1 = sum(l1, 1) (N, hw) l1_scale = l1 centerness_target / sum(centerness_target) (N, hw) (positive points are scaled by centerness_target, others are scale by 0 of centerness) final loss =sum(l1_scale) / where(centerness_target>0).size() (N, ) (where(centerness_target>0).size() is the positive number of each batch, sizeis (N, 1))
Is it right? The reg_loss reaches nan through several batches when it trains
@heiyuxiaokai Why do you use log1p
instead of log
? Moreover, I think l1 = sum(l1, 1)
should be l1 = mean(l1, 1)
.
@tianzhi0549 log(0) = nan, log1p(0) = log(0+1) = 0. I think log1p(x) ≈ log(x)? I will try l1 = mean(l1, 1). Thanks for your quick reply!
@heiyuxiaokai reg_target
should be always greater than 0.
@tianzhi0549 In reg_targets_flatten, there are always 22300(all points in p3,..,p7) box. Positive points' boxes > 0, and others' boxes = 0. reg_target[pos_inds] are the boxes which are greater than 0. I want caculate these boxes' loss and set other boxes' loss to 0.
@heiyuxiaokai I see. But in case you get inferior performance, please try to make the code here the same as ours. Thank you.
@tianzhi0549 Ok, thanks a lot.
@heiyuxiaokai No. It means
torch.abs(log(reg_target) - log(reg_pred)).mean()
.
in iou loss the reg_pred is across exp(), but log(exp(reg_pred)) == reg_pred. So should I only use
torch.abs(log(reg_target) - reg_pred).mean()
Does the network output the box offsets (l,r,t,b) normalized by image size? I tried to train fcos in another task and find the regression branch's output value is unstable.