region proposal network
A region proposal network is the small, fully-convolutional 'first stage' inside Faster R-CNN whose only job is to look at the shared feature map and shout out 'maybe-object here, and roughly this shape' at many locations. It is the learned replacement for Selective Search: instead of a fixed image-processing algorithm, proposals come from a network trained on data, and because it shares the backbone's features it is nearly free to run.
Mechanically, the RPN slides a small (e.g. 3×3) convolution over the feature map to mix local context, then branches into two 1×1-convolution heads. At each spatial location it considers k anchors (e.g. 9, from 3 scales × 3 ratios). The classification head outputs 2k objectness logits (object vs not-object per anchor); the regression head outputs 4k box-refinement deltas (the (t_x,t_y,t_w,t_h) offsets per anchor). Because it is fully convolutional, one forward pass scores every anchor over the whole image simultaneously.
Its labels come from IoU with ground-truth boxes: an anchor is a positive if it has IoU above ~0.7 with any true box (or is the highest-IoU anchor for some box, guaranteeing every object gets at least one), a negative if its IoU with all true boxes is below ~0.3, and ignored otherwise. The loss is binary cross-entropy on objectness plus smooth-L1 regression on positives only. Note the RPN is class-agnostic — it predicts 'object or not', leaving the actual class to the second stage.
At inference the RPN may emit tens of thousands of scored anchors; these are reduced by taking the top-N by score, refining them with the predicted deltas, clipping to the image, and running NMS to about 1,000–2,000 proposals that pass to the RoI head. The RPN is the conceptual seed of one-stage detection too: a dense, anchor-based, sliding objectness+regression head over feature maps is exactly what YOLO, SSD, and RetinaNet generalize — the difference is they classify into real categories in that same sweep, skipping the second stage.
On a 50×38 feature map with 9 anchors per cell, the RPN scores 50×38×9 ≈ 17,100 anchors in one pass; after top-N selection + NMS only ~2,000 proposals survive to the second stage.