Answers.Body: <p>There is no label for such bounding boxes, they are simply &quot;ignored&quot; during training. You can assign any value for their &quot;labels&quot;, then multiplying what ever loss these boxes generated with 0. If there is no loss, there is no gradient from these boxes.</p>
  <p>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 &quot;ignored&quot; boxes are marked 0.0. Then pair-wise multiply this count_boxes vector with the loss vector your model generated.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-25T05:20:26.417Z
Answers.Text: 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.
Answers.UserDisplayName: Abhisek Dash
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-26T15:17:37.963Z
Answers.Text: 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.
Answers.UserDisplayName: Son Nguyen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-23T19:33:34.047Z
Answers.LastActivityDate: 2021-07-23T19:43:48.020Z
Answers.LastEditDate: 2021-07-23T19:43:48.020Z
Answers.UserDisplayName: Son Nguyen
Body: <p>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.</p>
  <p>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.</p>
  
Tags: <tensorflow><python><keras><faster-r-cnn>
Title: Confusion about faster RCNN neither object nor background label
UserDisplayName: Abhisek Dash
ThreadText: # Confusion about faster RCNN neither object nor background label
  
  (Asked by: username_0 on 2021-06-22)
  
  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.
  
  **Tags:** tensorflow, python, keras, faster-r-cnn
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-23. Score: 1 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_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.  
  
  ---
  
  