3.4.13 · D1Convolutional Neural Networks

Foundations — Object detection (R-CNN, YOLO, SSD)

3,555 words16 min readBack to topic

Before you can read the parent note, you must be able to read its alphabet. This page picks up every symbol and idea it uses and builds it from nothing — a box, a number, a picture. Read top to bottom; each block only uses things defined above it.


1. The image as a grid of numbers

Everything starts with the picture. To a computer an image is not "a photo" — it is a rectangle of numbers.

Figure — Object detection (R-CNN, YOLO, SSD)

Notice grows downwards — the opposite of school graphs. Look at the figure: the top-left corner is and the bottom-right is the largest . This is a convention every detector obeys, so lock it in now.


2. The bounding box — the single most important object

Figure — Object detection (R-CNN, YOLO, SSD)

Look at the figure: the same red box is written both ways. The parent note uses letters constantly — now you know each is just one of the four numbers that pin down a rectangle.

Why these exact expressions?

  • The centre sits exactly halfway between the two corners. Halfway between two numbers on a line is their arithmetic mean — add them and split in two. So is literally "the point midway between the left edge and the right edge," and likewise for .
  • The width is the gap between the left edge and the right edge ; a gap between two positions on a line is found by subtracting them, hence . Because (right) is larger than (left), this is positive, as a width must be. Same story for .

Why this undoes the first? Starting from the centre, walk half a width left to reach the left edge and half a width right to reach the right edge — the box is symmetric about its own centre. This is the exact reverse of the mean/subtraction above, so you can always travel between the two descriptions in either direction with no loss.


3. Subscripts, the letter G and the letter P

The parent writes and . This looks scary; it is not.

The whole game of box regression (parent's boxed formulas) is: nudge until it matches . Everything with a hat, , means "our prediction of " — the hat means estimated, not exact.


4. Fractions and "relative to" — scale invariance

The parent keeps saying things like "offset as a fraction of box width" and writes . Why divide?

Figure — Object detection (R-CNN, YOLO, SSD)

Look at the figure: two boxes, one small one large, both shifted by "half a width." The pixel shifts differ wildly, but the fraction is for both. That single shared number is what makes learning easier.


5. The logarithm and the exponential — safe size changes

The parent uses and . New tools appear: , , and the network output .

Now the two mathematical tools those deltas ride on:


6. Probability, and the sigmoid

The parent writes , , and .

Figure — Object detection (R-CNN, YOLO, SSD)

Look at the S-shaped curve: very negative → near ; very positive → near ; → exactly (maximum uncertainty). This is why the parent wraps objectness in — it converts a free-floating output channel into an honest "yes/no confidence."

Recall Why must confidence be squashed to

? Because it is later multiplied with other probabilities (e.g. ). Multiplying probabilities only makes sense when each lives in . ::: A raw logit could be or and would corrupt the product.


7. IoU — how much two boxes overlap

The parent's confidence formula uses .

This single number scores "how good is this box?" We give it its own deep dive — see Intersection over Union (IoU). It also drives which guesses survive filtering — see Non-Maximum Suppression.


8. The grid: letters , , , and how cells are numbered

Before we can read a single , we must know what we are summing over. The parent lays a grid over the image.


9. Summation and the indicator

The YOLO loss is a wall of and . Two symbols only — and now , and are already defined.


10. Output tensor shape

The here means "shape dimensions," like saying a spreadsheet is "7 rows × 7 columns × 30 values deep." It is not multiplication of the final answer.


11. Feature map, stride, and warping


Prerequisite map

Image as grid of numbers x y

Bounding box x y w h

Proposal P vs Ground truth G

Fractions relative to size

log and exp for safe sizes

Feature map and stride

Grid S by S cells index i and j

IoU overlap score

Probability sigmoid softmax

Summation and indicator switch

Box regression

YOLO loss

Object Detection

Each foundation on the left must be solid before the box on its right makes sense; all roads end at the parent topic Object detection.


  • The starting network that only says "what": Image Classification.
  • Labelling every pixel instead of drawing boxes: Semantic Segmentation and its per-object cousin Instance Segmentation.
  • Pre-defined reference rectangles the parent leans on: Anchor Boxes.
  • Filtering overlapping guesses: Non-Maximum Suppression using Intersection over Union (IoU).
  • Reusing a trained backbone: Transfer Learning; steadying training: Batch Normalization; growing the dataset: Data Augmentation.

Equipment checklist

Cover the right side and test yourself. If any answer surprises you, reread that section.

  • In image coordinates, which way does grow? ::: Downwards, starting from the top edge at .
  • What four numbers describe a box in centre form? ::: Centre , centre , width , height .
  • How do you get the box centre from its corners, and why? ::: Take the arithmetic mean of the corners () — the mean is exactly the midpoint between two positions.
  • How do you get corner form back from centre form? ::: Walk half a width/height out from the centre: , (same for ).
  • What does mean and what does mean? ::: = proposal (a guess), = ground truth (the correct human-drawn box).
  • How can you tell (a box coordinate) from (a probability)? ::: A subscript letter after means the proposal box; parentheses around an event mean the probability operator.
  • What are ? ::: The raw nudges the network outputs; formulas turn them into the predicted box , and the targets are the correct nudges.
  • Why do we divide offsets by ? ::: To make them scale-invariant — a fraction of the box's own size means the same thing at every scale.
  • Which base is the in this topic, and why predict of the width ratio? ::: Natural log (base ); it makes grow/shrink symmetric, and then guarantees the recovered width is positive.
  • What does the sigmoid do to a raw logit ? ::: Squashes that objectness output channel into so it can be read as a probability.
  • In softmax, what does the index run over? ::: All classes from to ; the denominator sums over every class so the outputs total .
  • In words, what is IoU? ::: Shared area divided by combined area of two boxes; = identical, = no overlap.
  • How does the pair address a box, and what is the last valid ? ::: = cell index in row-major order (), running to ; = box number within that cell.
  • What does do inside a sum? ::: Acts as a switch — it's only when box in cell is responsible for an object, so the term is counted only then.
  • What do , , stand for in YOLO? ::: Grid side length, boxes per cell, number of classes.
  • Why is a feature-map size like never literally stored, and what replaces it? ::: Real sizes are integers: flooring (VALID → 37) or padding then ceiling (SAME → 38).