The role of anchor boxes in detectors
anchor-based detection.
anchors are reference boxes of set scales and ratios; the model regresses offsets, framing detection as classification plus refinement; downsides are tuning, imbalance.
anchors are not final boxes.
What's really being asked
The interviewer checks that you understand anchors as a design device that makes dense detection tractable, plus the practical pain they introduce.
The full answer
Problem solved: objects vary in position, scale, and aspect ratio, and a location may contain several objects. Anchors address this by placing a fixed set of reference boxes of various scales and aspect ratios at every spatial location of the feature map. The network then, per anchor, predicts an objectness or class score and regresses small offsets to adjust the anchor toward the true box. This reframes detection as classification plus bounding-box refinement relative to known priors, which is easier to learn than regressing boxes from scratch and naturally handles multiple, overlapping objects. Challenges: the scales and aspect ratios are hyperparameters that need tuning per dataset; most anchors are background, creating severe class imbalance addressed by focal loss or hard negative mining; performance suffers if anchor shapes mismatch the data, such as very tall or tiny objects; and dense anchors produce many candidate boxes requiring NMS. These pains motivated anchor-free detectors like FCOS and DETR.
The mistakes people make
Treating anchors as the final predicted boxes rather than priors that get refined. Or ignoring class imbalance. Or assuming one universal anchor set works for any dataset.
What usually comes next
How do you choose anchor scales and ratios, perhaps via clustering ground-truth boxes. How does focal loss tackle anchor imbalance. How do anchor-free detectors avoid these issues. How is an anchor matched to a ground-truth box via IoU.
A concrete example
For a pedestrian dataset, you cluster the ground-truth boxes with k-means and find most are tall and narrow, so you set anchor aspect ratios accordingly rather than using generic squares. At each feature-map cell the model scores its tiled anchors for objectness and class, and regresses offsets that nudge the best-matching tall anchor to tightly fit each person. An anchor is assigned to a ground-truth box when their IoU is high enough, which defines the positive training targets. Finally NMS removes the overlapping duplicate boxes that the dense anchors inevitably produce, leaving one tight box per pedestrian.
Interview question
What best describes how a detector uses an anchor box?
- a.The model scores the anchor and regresses offsets to fit the true objectCorrect
- b.Each location uses exactly one anchor of fixed size
- c.The anchor is the final output box reported directly
- d.Anchors replace the need for any feature map
Why? this is the answer
Anchors are priors: the network classifies each and predicts offsets to refine it toward the real box. They are not final outputs, multiple shapes are tiled per location, and feature maps are still required.
Just read this? Test yourself on what you have been reading.
Read the original → d2l.ai
- #anchor-boxes
- #object-detection
- #bounding-box-regression
- #class-imbalance
- #anchor-free
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles