Anchor Boxes

Imagine training a detector to find both a bus filling an entire highway lane and a distant road sign no larger than a postage stamp. Both objects appear in the same image. A single regression head that predicts raw pixel coordinates for "the box" struggles. It has no prior about how big or how tall the object might be. As a result, gradients from tiny objects and huge objects fight over the same weights. Anchor boxes solve this by giving the network a dense set of pre-defined reference boxes. These boxes are tiled across the image at every scale and aspect ratio the designer expects to see. The network then predicts small corrections relative to the nearest anchor, instead of the object location from scratch. This reframing — from absolute localization to relative regression against a good prior — is one of the ideas that made modern object detection fast and trainable end-to-end. It turns "where is the object" into "which anchor is responsible, and how do we nudge it." This converts a hard geometric search into a classification-plus-regression problem that convolutional networks are already good at. Anchors appear, in one guise or another, in Faster R-CNN's Region Proposal Network, in single-shot detectors like SSD and YOLOv2/v3, and in the design space that later anchor-free detectors explicitly reacted against. The big picture is this: a detector needs to (1) decide where objects might be, (2) decide what they are, and (3) refine exactly where their boundaries lie. Anchor boxes handle the coupling between (1) and (3) elegantly. Every spatial location gets several candidate shapes. Each candidate is scored against ground truth during training. The network learns to regress a tight box only for anchors that overlap a real object well. This article explains precisely how anchors are generated, matched to ground truth, encoded into regression targets, and decoded back into predictions. It also covers the complexity, the pitfalls, and the history of the idea. This article delivers a full mechanical account: the anchor generation grid, the matching (assignment) rule, the parameterization used for regression targets, worked numeric traces, and a discussion of why the scheme is efficient and trainable. It also discusses where this idea sits relative to Object Detection Fundamentals and the detector families that popularized it.

Key takeaways
  • Anchor boxes are a fixed, dense grid of reference boxes (multiple scales and aspect ratios) placed at every feature map location.
  • Detectors don't predict object coordinates directly; they predict a classification score and a small offset per anchor.
  • Ground-truth boxes are matched to anchors by Intersection-over-Union (IoU), usually with a positive and negative threshold and a hard-negative or ignore band between them.
  • Regression targets are parameterized as scale-invariant offsets (translation and log-scale), so the loss is well-conditioned regardless of object size.
  • Anchors let one network head handle many object sizes/shapes at each location, at the cost of needing to hand-tune scales, ratios, and thresholds.
  • The anchor idea underlies The R-CNN Family's Region Proposal Network and Single-Shot Detectors like SSD/YOLOv2, and motivated later anchor-free alternatives.
The core insight

Anchor boxes turn object localization into predicting small, scale-normalized corrections to a dense set of pre-defined reference boxes, rather than predicting raw coordinates from nothing.

The idea

An anchor box is a fixed-size, fixed-aspect-ratio rectangle placed at a specific location in the image, used as a reference from which the detector predicts a refined bounding box. Anchors are not learned positions — they are a deterministic geometric grid, defined once from a small set of hyperparameters: a set of scales {s1,…,sm}\{s_1, \dots, s_m\} (areas, typically expressed as area\sqrt{\text{area}}) and a set of aspect ratios {r1,…,rk}\{r_1, \dots, r_k\} (width-to-height ratios such as 1:11{:}1, 1:21{:}2, 2:12{:}1). At every location on a convolutional feature map, the detector instantiates one anchor per (scale, ratio) combination, giving m×km \times k anchors per location and, over an H×WH \times W feature map, H⋅W⋅m⋅kH \cdot W \cdot m \cdot k anchors in total. Each anchor is treated as a candidate detection slot. During training, every anchor is assigned a label — positive (matched to some ground-truth object), negative (background), or ignored (ambiguous overlap) — based on its Intersection-over-Union (IoU) with ground-truth boxes. Positive anchors additionally receive a regression target: the parameterized offset needed to transform the anchor into the matching ground-truth box. The network head, at that same spatial location, predicts an objectness/class score and a 4-vector of offsets; the loss compares predicted offsets to targets only for positive (and sampled negative) anchors. At inference time, the offsets are decoded by applying them to the anchor geometry, producing the final predicted box, which is then filtered by score threshold and non-maximum suppression. The key conceptual shift is that the search space of possible boxes is discretized in advance by the anchors, and the learning problem becomes local refinement plus classification. This is why anchors are often described as encoding a strong geometric prior: rather than a network having to learn, from pixels alone, that "objects near this pixel tend to be roughly 40×80 pixels," the anchor grid supplies that scale explicitly, and the network only needs to learn the residual correction and the presence/absence decision.

How it works

Step 1 — Anchor generation. For a feature map of size H×WH \times W with stride ss (the downsampling factor from image to feature map), each cell (i,j)(i, j) corresponds to an image-space center

cx=(j+0.5)⋅s,cy=(i+0.5)⋅s.c_x = (j + 0.5)\cdot s, \qquad c_y = (i + 0.5)\cdot s.

For every combination of scale aa (anchor area, or a base size times a scale factor) and aspect ratio rr, the anchor width and height are

w=ar,h=a/r,w = a \sqrt{r}, \qquad h = a / \sqrt{r},

(one common convention; SSD/Faster R-CNN vary slightly in exact formula but the idea — area fixed, width/height set by ratio — is the same). The anchor is the box centered at (cx,cy)(c_x, c_y) with that width and height.

Step 2 — Matching / assignment. Given ground-truth boxes {Gk}\{G_k\} for an image, compute IoU between every anchor AiA_i and every GkG_k. A standard two-threshold rule (used in Faster R-CNN, SSD):

  • If max⁡kIoU(Ai,Gk)≥τpos\max_k \text{IoU}(A_i, G_k) \ge \tau_{\text{pos}} (e.g., 0.7), label AiA_i positive, assigned to arg⁡max⁡kIoU(Ai,Gk)\arg\max_k \text{IoU}(A_i, G_k).
  • If max⁡kIoU(Ai,Gk)<τneg\max_k \text{IoU}(A_i, G_k) < \tau_{\text{neg}} (e.g., 0.3), label AiA_i negative (background).
  • Otherwise, label AiA_i ignored (excluded from the loss) to avoid confusing ambiguous cases.
  • To guarantee every ground-truth box has at least one positive anchor, additionally force the single best-matching anchor for each GkG_k to be positive, regardless of its absolute IoU.

Step 3 — Regression target parameterization. For each positive anchor A=(xa,ya,wa,ha)A = (x_a, y_a, w_a, h_a) (center-x, center-y, width, height) matched to ground truth G=(xg,yg,wg,hg)G = (x_g, y_g, w_g, h_g), the regression target is:

tx=xg−xawa,ty=yg−yaha,tw=log⁡wgwa,th=log⁡hgha.t_x = \frac{x_g - x_a}{w_a}, \quad t_y = \frac{y_g - y_a}{h_a}, \quad t_w = \log\frac{w_g}{w_a}, \quad t_h = \log\frac{h_g}{h_a}.

This parameterization is scale-invariant: translation offsets are normalized by anchor size, and size offsets are logarithmic ratios, so a target for a huge object and a target for a tiny object live on comparable numeric scales — this is essential for a single regression head with one loss weighting to train stably across scales.

Step 4 — Loss. The network predicts, per anchor, a class score (or objectness) p^\hat{p} and offsets (t^x,t^y,t^w,t^h)(\hat t_x, \hat t_y, \hat t_w, \hat t_h). The total loss sums a classification loss (cross-entropy or focal loss) over all sampled anchors, and a regression loss (typically smooth-L1 / Huber) over positive anchors only:

L=1Ncls∑iLcls(p^i,pi∗)  +  λ1Nreg∑i∈posLreg(t^i,ti∗).L = \frac{1}{N_{\text{cls}}}\sum_i L_{\text{cls}}(\hat p_i, p_i^*) \;+\; \lambda \frac{1}{N_{\text{reg}}}\sum_{i \in \text{pos}} L_{\text{reg}}(\hat t_i, t_i^*).

Step 5 — Decoding at inference. Given a predicted offset (t^x,t^y,t^w,t^h)(\hat t_x,\hat t_y,\hat t_w,\hat t_h) for anchor AA, invert the parameterization:

x^=t^xwa+xa,y^=t^yha+ya,w^=waet^w,h^=haet^h.\hat x = \hat t_x w_a + x_a, \quad \hat y = \hat t_y h_a + y_a, \quad \hat w = w_a e^{\hat t_w}, \quad \hat h = h_a e^{\hat t_h}.

Boxes are then filtered by class score threshold and passed through non-maximum suppression. ```

# ANCHOR GENERATION function generate_anchors(feature_h, feature_w, stride, scales, ratios): anchors = [] for i in 0 .. feature_h - 1: for j in 0 .. feature_w - 1: cx = (j + 0.5) stride cy = (i + 0.5) stride for a in scales: for r in ratios: w = a sqrt(r) h = a / sqrt(r) anchors.append(Box(cx, cy, w, h)) # center-form return anchors # length = feature_h feature_w |scales| |ratios|

# MATCHING (TRAINING TIME) function match_anchors(anchors, gt_boxes, pos_thresh, neg_thresh): labels = array(len(anchors), fill = IGNORE) targets = array(len(anchors), fill = None) assigned_gt = array(len(anchors), fill = -1) iou_matrix = compute_iou(anchors, gt_boxes) # |anchors| x |gt|

# (a) best anchor per ground-truth box is forced positive for k in 0 .. len(gt_boxes) - 1: i_best = argmax_i( iou_matrix[:, k] ) labels[i_best] = POSITIVE assigned_gt[i_best] = k

# (b) threshold-based assignment for the rest for i in 0 .. len(anchors) - 1: best_k = argmax_k( iou_matrix[i, :] ) best_iou = iou_matrix[i, best_k] if labels[i] == POSITIVE: continue # already forced positive if best_iou >= pos_thresh: labels[i] = POSITIVE assigned_gt[i] = best_k else if best_iou < neg_thresh: labels[i] = NEGATIVE

# else: stays IGNORE

# (c) compute regression targets for positives for i in 0 .. len(anchors) - 1: if labels[i] == POSITIVE: targets[i] = encode(anchors[i], gt_boxes[assigned_gt[i]]) return labels, targets function encode(anchor, gt): tx = (gt.cx - anchor.cx) / anchor.w ty = (gt.cy - anchor.cy) / anchor.h tw = log(gt.w / anchor.w) th = log(gt.h / anchor.h) return (tx, ty, tw, th)

# DECODING (INFERENCE TIME) function decode(anchor, t): x = t.tx anchor.w + anchor.cx y = t.ty anchor.h + anchor.cy w = anchor.w exp(t.tw) h = anchor.h exp(t.th) return Box(x, y, w, h) ```

Figure
Anchor grid at one feature-map cell: multiple scales × aspect ratios centered at the same point
feature map (H×W cells) cell center (i,j) Per-cell anchors: 1:1, scale s1 2:1, scale s1 1:2, scale s1 2:1, scale s2 Network predicts, per anchor: class score + offset (tx,ty,tw,th) Decoded box = anchor warped by offset

Complexity & correctness

Time complexity of anchor generation. Generating anchors is a fixed enumeration: O(H⋅W⋅m⋅k)O(H \cdot W \cdot m \cdot k) boxes, each built in O(1)O(1) time from closed-form arithmetic. This is cheap — for a typical feature map H=W=50H=W=50 with m=3m=3 scales and k=3k=3 ratios, that is 50×50×9=22,50050 \times 50 \times 9 = 22{,}500 anchors, generated once (they don't depend on the image content, only on the feature map size, so they can be precomputed and cached for a fixed input resolution).

Time complexity of matching. Computing the full IoU matrix between NaN_a anchors and NgN_g ground-truth boxes costs O(Na⋅Ng)O(N_a \cdot N_g) if done densely. Since NgN_g (objects per image) is typically small (single digits to low hundreds) while NaN_a can be tens of thousands, this is effectively linear in the number of anchors, O(Na)O(N_a) for constant NgN_g. Assignment (argmax over rows/columns) is also O(Na⋅Ng)O(N_a \cdot N_g). This is affordable per training image and is why anchor-based detectors can densely supervise every location without a combinatorial search over box proposals.

Space complexity. Storing NaN_a anchors (4 floats each) is O(Na)O(N_a); storing per-anchor labels and regression targets is likewise O(Na)O(N_a). Since anchors are geometry-only (no learned parameters), the memory cost is a small constant-factor overhead compared to the feature maps and network weights themselves.

Why the scale-invariant parameterization is the correct choice, not an arbitrary one. If regression targets were raw pixel differences (xg−xa)(x_g - x_a), the loss magnitude — and hence the gradient scale — would depend on absolute object size and image resolution: a 3-pixel error on a 10-pixel object is catastrophic, but a 3-pixel error on a 300-pixel object is negligible, yet an unnormalized L2/L1 loss would weight them identically in raw pixels. Dividing by anchor width/height (tx,tyt_x, t_y) makes translation error relative to object scale; using log⁡\log ratios for width/height (tw,tht_w, t_h) makes size error symmetric and additive under composition (multiplying width by 2 and predicting the wrong direction costs the same as dividing by 2), and keeps the target finite and centered near 0 when anchor and ground truth are close — a first-order Taylor argument: for wg≈waw_g \approx w_a, log⁡(wg/wa)≈(wg−wa)/wa\log(w_g/w_a) \approx (w_g - w_a)/w_a, so near a good match the parameterization reduces to a simple normalized difference, matching the translation terms' form and giving a well-conditioned loss landscape across all four coordinates.

Why the matching rule is correct (recall guarantee). The "force the best anchor per ground truth to be positive" rule (Step 2a) is not an optimization heuristic; it is a coverage guarantee. Without it, a small or unusually shaped ground-truth object whose best IoU with any anchor falls below τpos\tau_{\text{pos}} would receive zero positive anchors and could never be learned no matter how the regression head is trained — the gradient for that object would simply never appear in the loss. Forcing the arg-max anchor to be positive guarantees every ground-truth instance contributes at least one training signal, closing this gap; the IoU-threshold rule on top of it lets multiple anchors match large or elongated objects, giving redundancy that helps recall at inference (several anchors "fire" for the same object, and non-maximum suppression consolidates them).

Tradeoffs. Anchors introduce hyperparameters (how many scales, ratios, thresholds) that must be tuned or learned from data statistics (e.g., k-means over ground-truth box shapes, as in YOLOv2). Too coarse a set of scales/ratios under-covers unusual object shapes, hurting recall; too fine a set inflates NaN_a and slows training/inference and increases class imbalance (the vast majority of anchors are negative, requiring hard-negative mining or focal loss to keep the loss from being swamped by easy background). This design burden is exactly what anchor-free detectors later tried to remove, at the cost of different assignment heuristics.

Worked example

Consider a 4×44\times4 feature map (16 cells) from an image of size 128×128128\times128, so stride s=32s = 32. Use one scale a=64a = 64 (area-scale in pixels) and two aspect ratios r∈{1,2}r \in \{1, 2\} (square and 2:1 wide), giving 22 anchors per cell, 3232 anchors total. Take the cell at (i,j)=(1,2)(i,j) = (1,2) (0-indexed): center cx=(2+0.5)⋅32=80c_x = (2+0.5)\cdot 32 = 80, cy=(1+0.5)⋅32=48c_y = (1+0.5)\cdot 32 = 48.

  • Anchor A (ratio 1): w=641=64w = 64\sqrt{1}=64, h=64/1=64h = 64/\sqrt{1}=64 → box center (80,48)(80,48), size 64×6464\times64.
  • Anchor B (ratio 2): w=642≈90.5w = 64\sqrt{2}\approx 90.5, h=64/2≈45.3h = 64/\sqrt{2}\approx 45.3 → box center (80,48)(80,48), size 90.5×45.390.5\times45.3.

Suppose the ground truth is a car: G=(xg,yg,wg,hg)=(85,50,70,50)G = (x_g,y_g,w_g,h_g) = (85, 50, 70, 50) (center-form).

IoU check. Anchor A: (80,48,64,64)(80,48,64,64) → corners [48,16][48,16] to [112,80][112,80]. GG corners: [50,25][50,25] to [120,75][120,75]. Intersection: x-range [max⁡(48,50),min⁡(112,120)]=[50,112][\max(48,50),\min(112,120)] = [50,112] → width 62; y-range [max⁡(16,25),min⁡(80,75)]=[25,75][\max(16,25),\min(80,75)] = [25,75] → height 50. Intersection area =62×50=3100= 62\times50 = 3100. Union =64⋅64+70⋅50−3100=4096+3500−3100=4496= 64\cdot64 + 70\cdot50 - 3100 = 4096+3500-3100 = 4496. IoU ≈3100/4496≈0.69\approx 3100/4496 \approx 0.69. With τpos=0.7\tau_{\text{pos}}=0.7, this narrowly misses the threshold — but suppose across the whole anchor set this is still the single highest-IoU anchor for GG; by the forced-positive rule, Anchor A is still labeled positive for GG regardless.

Encoding the regression target for Anchor A:

tx=85−8064=0.0781,ty=50−4864=0.0313t_x = \frac{85-80}{64} = 0.0781, \quad t_y = \frac{50-48}{64} = 0.0313
tw=log⁡7064=log⁡(1.0938)≈0.0896,th=log⁡5064=log⁡(0.7813)≈−0.2469t_w = \log\frac{70}{64} = \log(1.0938) \approx 0.0896, \quad t_h = \log\frac{50}{64} = \log(0.7813) \approx -0.2469

The network head at cell (1,2)(1,2), anchor-slot A, is trained to regress toward (0.0781,0.0313,0.0896,−0.2469)(0.0781, 0.0313, 0.0896, -0.2469) and to classify this anchor as "car" (positive).

Decoding (inference-time check). Suppose at test time the network predicts t^=(0.07,0.03,0.09,−0.24)\hat t = (0.07, 0.03, 0.09, -0.24) for this anchor. Decode:

x^=0.07⋅64+80=84.48,y^=0.03⋅64+48=49.92\hat x = 0.07\cdot 64 + 80 = 84.48, \qquad \hat y = 0.03\cdot 64 + 48 = 49.92
w^=64⋅e0.09≈64⋅1.0942≈70.03,h^=64⋅e−0.24≈64⋅0.7866≈50.34\hat w = 64\cdot e^{0.09} \approx 64\cdot 1.0942 \approx 70.03, \qquad \hat h = 64\cdot e^{-0.24}\approx 64\cdot 0.7866\approx 50.34

The decoded box (84.48,49.92,70.03,50.34)(84.48, 49.92, 70.03, 50.34) is nearly identical to the true G=(85,50,70,50)G=(85,50,70,50) — the small offset the network had to learn was tiny precisely because Anchor A was already a good geometric prior for this object.

QuantityAnchor AGround truth GG
center (x,y)(x,y)(80,48)(80, 48)(85,50)(85, 50)
size (w,h)(w,h)(64,64)(64, 64)(70,50)(70, 50)
IoU with GG0.690.69—
regression target (tx,ty,tw,th)(t_x,t_y,t_w,t_h)(0.078,0.031,0.090,−0.247)(0.078, 0.031, 0.090, -0.247)—
decoded prediction (example)—(84.48,49.92,70.03,50.34)(84.48, 49.92, 70.03, 50.34)

Common pitfalls & traps

PitfallWhy it happensFix
Forgetting the "best-anchor-per-GT" force-positive ruleSmall/odd-shaped objects may never clear τpos\tau_{\text{pos}} with any anchorAlways guarantee ≥1 positive anchor per ground-truth box
Mismatched anchor scale set vs. dataset object-size distributionAnchors chosen by convention rather than data statisticsCluster ground-truth box sizes (e.g., k-means, as in YOLOv2) to set scales/ratios
Ignoring class imbalance (thousands of negatives vs. few positives)Dense anchor grids make positives rare (often <1% of anchors)Hard-negative mining, focal loss, or capped negative sampling ratio
Using raw pixel-difference regression instead of scale-normalized targetsSeems simpler, but conditions the loss poorly across object sizesUse the (tx,ty,tw,th)(t_x,t_y,t_w,t_h) log-scale parameterization
Confusing feature-map stride with anchor center placementOff-by-one/half-cell errors misalign anchors with actual receptive fieldsCenter anchors at (j+0.5)⋅s(j+0.5)\cdot s, not j⋅sj\cdot s, and verify against the network's true receptive field
Treating "ignored" anchors as negatives during loss computationInflates false penalty for ambiguous, near-threshold overlapsExplicitly mask ignored anchors out of both classification and regression loss

Pioneers & history

Anchor boxes as a named, systematized mechanism entered mainstream computer vision through region-proposal and single-shot detection research in the mid-2010s, though the underlying idea — multi-scale, multi-aspect-ratio template windows — traces back further to sliding-window and part-based detection work.

Origins · 1 minShaoqing Ren and how this was discovered
SR
Shaoqing Ren
1988–present · Co-author of Faster R-CNN, which introduced the Region Proposal Network and popularized the term "anchor" for learned-region reference boxes

History
2001
— Viola–Jones sliding-window face detector uses fixed-size scanning windows, a conceptual ancestor of dense multi-scale search.
2010
— Deformable Parts Models use multi-scale, multi-aspect-ratio root and part filters, foreshadowing anchor-style templates.
2015
— Faster R-CNN introduces the Region Proposal Network with explicit "anchor boxes" at multiple scales and ratios per location.
2015–2016
— SSD extends anchors ("default boxes") across multiple feature-map resolutions for single-shot multi-scale detection.
2017
— YOLOv2 replaces hand-picked ratios with k-means-clustered anchor priors derived from training-set box statistics.
2019
onward — Anchor-free detectors (e.g., FCOS, CenterNet-style designs) argue anchors add unnecessary hyperparameters, reviving direct point/keypoint-based localization.

Where this matters

Anchor-based design is the backbone of two major detector families taught alongside this topic. In the two-stage family — The R-CNN Family — Faster R-CNN's Region Proposal Network uses anchors to generate object proposals cheaply from a shared convolutional feature map, replacing external proposal algorithms like Selective Search and enabling end-to-end training. In the one-stage family — Single-Shot Detectors such as SSD and YOLOv2/v3 — anchors (sometimes called "default boxes" or "priors") are tiled across multiple feature-map resolutions so that shallow, high-resolution layers handle small objects and deep, low-resolution layers handle large ones, all within a single forward pass with no separate proposal stage. Production systems in autonomous driving perception stacks, retail shelf analytics, aerial and satellite imagery pipelines, and video surveillance historically relied on anchor-based detectors for their favorable accuracy/speed tradeoff and mature tooling; many current-generation detectors have shifted toward anchor-free or query-based (transformer) designs, but understanding anchor mechanics remains essential for interpreting model configs, benchmark comparisons, and the design decisions of frameworks like Faster R-CNN, SSD, and RetinaNet that still anchor (pun intended) much of the field's baseline literature and remain widely deployed.

Ask the tutor: How do the anchor scale and aspect-ratio choices in SSD differ across its multiple feature-map resolutions, and why?

Are anchor boxes learned or fixed?

The anchors themselves — their positions, scales, and aspect ratios — are fixed geometric priors defined before training, generated deterministically from the feature map size and a small set of hyperparameters. They are not updated by gradient descent. What the network learns is (a) how to classify each anchor as object/background/class and (b) how to regress a small offset from each anchor toward the true box. Some pipelines do tune the anchor hyperparameters using data statistics before training (e.g., k-means clustering over ground-truth box shapes, as in YOLOv2), but that clustering happens once, offline, not during the network's gradient-based training loop.

Why not just predict bounding box coordinates directly, without anchors?

Direct coordinate regression from a single global feature vector was tried in early detectors and struggles because the network must implicitly learn an enormous, unconstrained mapping from image content to absolute pixel coordinates across wildly varying object scales, with no structural prior to guide it. Anchors decompose this into a dense set of local decisions: at each location, is there an object roughly this size/shape, and if so what small correction is needed? This makes the regression targets small, bounded, and comparable across scales (via the log-scale parameterization), which is far easier for a convolutional network to learn stably and converges faster in practice.

How are the numbers of scales and aspect ratios chosen?

Historically these were chosen by inspecting the distribution of object sizes and shapes in the target dataset — Faster R-CNN used 3 scales × 3 ratios (9 anchors/location) based on typical PASCAL VOC/COCO object statistics. YOLOv2 improved on hand-picked values by running k-means clustering (using 1 − IoU as the distance metric) over all ground-truth box shapes in the training set, choosing the cluster centers as anchor priors. More scales/ratios improve coverage of unusual shapes but increase computation and worsen class imbalance, so the choice is a recall-versus-efficiency tradeoff tuned per dataset.

What happens to anchors that don't match any object?

The vast majority of anchors overlap no ground-truth object and are labeled negative (background); they contribute only to the classification loss (they should be scored as "not an object" or low objectness) and receive no regression target, since there is nothing to regress toward. Because negatives vastly outnumber positives in a dense anchor grid, most detectors either subsample negatives (hard-negative mining, keeping a fixed positive:negative ratio) or use a loss designed for extreme imbalance, such as focal loss, so that overwhelming background evidence does not drown out the sparse positive signal.

How do anchors interact with multiple feature map resolutions?

Single-shot detectors like SSD place anchors on several feature maps of different resolutions simultaneously, extracted from different depths of the backbone network. Shallow, high-resolution feature maps have anchors covering smaller pixel areas (appropriate for small objects, since each cell corresponds to a smaller receptive field), while deep, low-resolution feature maps use anchors covering larger areas (appropriate for large objects). Matching and loss computation proceed identically at each resolution — the same IoU-thresholding and encode/decode math applies — just repeated per feature-map level, and predictions from all levels are pooled before non-maximum suppression.

Why do anchor-free detectors exist if anchors work well?

Anchors require several hand-tuned hyperparameters (scale set, ratio set, IoU thresholds) that must be retuned per dataset, and the dense anchor grid creates heavy class imbalance and extra computation from anchors that never match anything. Anchor-free detectors instead predict object properties directly from feature map locations or keypoints (e.g., center points and a size/offset regression, or corner-pair detection), removing the anchor-design burden and often simplifying the matching rule to "is this point inside the object." They can achieve competitive accuracy with a smaller hyperparameter surface, though anchor-based designs remain a strong, well-understood baseline in the literature and in production systems.

Before this

Where this leads