broadinstitute / keras-rcnn

Keras package for region-based convolutional neural networks (RCNNs)
Other
553 stars 223 forks source link

Change rpn classification loss layer. #56

Closed hgaiser closed 6 years ago

hgaiser commented 6 years ago

As mentioned here, this is what I propose. I have not tested this, so I don't know if it is working or not. This PR only changes the classification loss, I didn't touch the regression loss.

Basically what this does is:

  1. Reshape predicted classifications to (None, 2) (rpn_labels is already (None,).
  2. Select those classifications that have a label which is not equal to -1. These are labelled as background (0) or foreground (1). -1 is reserved for "don't care".
  3. Similarly, filter out rpn_labels with -1.
  4. Execute categorical_crossentropy on the resulting two tensors (rpn_labels.shape = (None,) and rpn_classification.shape = (None, 2)).

I would love to hear some feedback on this approach of RPN losses.