tianzhi0549 / FCOS

FCOS: Fully Convolutional One-Stage Object Detection (ICCV'19)
https://arxiv.org/abs/1904.01355
Other
3.28k stars 630 forks source link

Why use exp function in regression branch #67

Open lih627 opened 5 years ago

lih627 commented 5 years ago

In the paper, it said

we employ exp(x) to map any real number to (0, ∞) on the top of the regression branch.

I wonder to know why to use exp function in regression branch. Use exp() at the last layer output as the regression results? (as the paper notes l,t,r,b)

tianzhi0549 commented 5 years ago

@lih627 Because l, t, r, b are always positive.

jszgz commented 4 years ago

@lih627 Because l, t, r, b are always positive.

if self.norm_reg_targets: bbox_pred = F.relu(bbox_pred) if self.training: bbox_reg.append(bbox_pred) else: bbox_reg.append(bbox_pred * self.fpn_strides[l]) else: bbox_reg.append(torch.exp(bbox_pred)) https://github.com/tianzhi0549/FCOS/blob/master/fcos_core/modeling/rpn/fcos/fcos.py#L112 If l, t, r, b are always positive, why do you use relu? What's more, since self.norm_reg_targets is True in your yaml, the code doesn't use exp() but only use scale factor?

marius-sm commented 4 years ago

I'm also interested if there is any reason to prefer exp over any other function that maps (-∞, ∞) to (0, ∞). I tried relu without scale factor and it worked well, especially with high learning rates, whereas exp would cause inf values to appear. Softplus also worked.

tianzhi0549 commented 4 years ago

@marius-sm In an earlier version, we did not normalize the regression targets and they have a large range, for example, from 0 to 1334. Also, we do not want the network's outputs are too large. Thus, we need a function that can map a small value (the network's outputs) to a large value (our regression targets). An exponential function is a good choice.

marius-sm commented 4 years ago

@tianzhi0549 ok, thanks for your answer.

CS-Jackson commented 4 years ago

Hi, @tianzhi0549 . I was wondering how the norm_reg_targets work? When I use mmdetection to train FCOS. I got 38.5 mAP without norm_reg_targets. However, when I impelemetn the norm_reg_targets by myself, I only achieve 38.3 mAP. Did I miss something? I only add the code as follow: First, I use the code in fcos.py: if self.norm_reg_targets: bbox_pred = F.relu(bbox_pred) if self.training: bbox_reg.append(bbox_pred) else: bbox_reg.append(bbox_pred * self.fpn_strides[l]) Second, the code in loss.py if self.norm_reg_targets: reg_targets_per_level = reg_targets_per_level / self.fpn_strides[level]

pierrelzw commented 1 year ago

@marius-sm In an earlier version, we did not normalize the regression targets and they have a large range, for example, from 0 to 1334. Also, we do not want the network's outputs are too large. Thus, we need a function that can map a small value (the network's outputs) to a large value (our regression targets). An exponential function is a good choice.

I only see a Scale operation with learnable parameters, the norm in norm_reg_targets is not really normalization, right?