0
$\begingroup$

I am trying to construct a faster RCNN from scratch using KERAS. I am generating the tensor which contains whether anchor at each location corresponds to object or background or neither for training the RPN. The output tensor for the RPN is suppose H x W x L where the L dimension corresponds to whether an object is detected or is background or neither based on IOU thresholds.

My question is this: What should be the label value for neither an object nor background label and how to stop the gradient flow for this label.

$\endgroup$
1
$\begingroup$

There is no label for such bounding boxes, they are simply "ignored" during training. You can assign any value for their "labels", then multiplying what ever loss these boxes generated with 0. If there is no loss, there is no gradient from these boxes.

You can do that by defining a count_boxes vector with binary values. Object and background are counted, so value is 1.0. The remaining "ignored" boxes are marked 0.0. Then pair-wise multiply this count_boxes vector with the loss vector your model generated.

$\endgroup$
2
  • $\begingroup$ I have labelled object with (1,0) , not object with (0,1) and neither object nor background with (-1,-1). What if I first select the labels containing object/not object before calculating the loss using tf.where? This way I can ignore the (-1,-1) labels. Will this approach work? And thank you for your response. $\endgroup$ Jul 25 at 5:20
  • 1
    $\begingroup$ Yes, I think using tf.where should work just fine. You should also pay attention to the imbalance between object and background, they are often heavily skewed. And you are welcome. $\endgroup$
    – Son Nguyen
    Jul 26 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.