Skip to content
DeepForgeby svx
All problems
EasyComputer Visioncv-323

RPN Sample Counts

Problem

Compute how many positive and negative anchors an RPN mini-batch samples.

Take min(positives, batch_size // 2) positives, then fill the rest of the batch with min(negatives, batch_size - positives) negatives. labels uses 1 for positive, 0 for negative and -1 for ignored anchors. Return [num_pos, num_neg].

Test cases

case 1
in: [[1,0,0,0,0,0,-1],4]
expected: [1,3]
case 2
in: [[1,1,0,0,-1,0],4]
expected: [2,2]
case 3
in: [[0,0,0,0,0,0,0,0,0,0],8]
expected: [0,8]
case 4
in: [[1,1,1,1,1,1,1,1,1,1],5]
expected: [2,0]
Starter codePython
def rpn_sample_counts(labels, batch_size):
    # Your code here
    pass

4 test cases · run your code against them in the editor