0

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.

1 Answers1

1

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.

Son Nguyen
  • 26
  • 2
  • 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. – Abhisek Dash Jul 25 '21 at 05:20
  • 1
    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. – Son Nguyen Jul 26 '21 at 15:17