3.4.4Convolutional Neural Networks

Feature maps and receptive fields

3,197 words15 min readdifficulty · medium2 backlinks

Core Intuition


What Are Feature Maps?

Why this formula? Start with the padded input size H+2pH + 2p. Subtract the filter "reach" kk to get the last valid position. Divide by stride ss to count how many steps fit. Add 1 because positions are fencepost-counted (if you can place the filter at positions 0, 1, 2, you have 3 outputs, not 2).

If you have CoutC_{\text{out}} filters in a convolutional layer, you produce CoutC_{\text{out}} feature maps stacked as a 3D tensor of shape (Cout,Hout,Wout)(C_{\text{out}}, H_{\text{out}}, W_{\text{out}}). Each channel is the "opinion" of one filter.


What Is a Receptive Field?

Key insight: A neuron in layer LL doesn't "see" the input directly. It sees layer L1L-1, which saw layer L2L-2, etc. The receptive field accumulates this chain.

Derivation from scratch:

  1. Base case: At layer 0 (the input), R0=1R_0 = 1 (a pixel sees itself).
  2. Layer 1: A k1×k1k_1 \times k_1 filter with stride s1s_1 looks at k1k_1 consecutive pixels in the input. The center pixel's receptive field is k1k_1 wide. If stride s1>1s_1 > 1, adjacent outputs skip s1s_1 input pixels, but the receptive field size is still k1k_1 for the first layer: R1=k1R_1 = k_1.
  3. Layer 2: Each pixel in layer 1 has R1=k1R_1 = k_1. Layer 2's k2×k2k_2 \times k_2 filter spans k2k_2 pixels in layer 1. Each of those layer-1 pixels covers k1k_1 input pixels, and layer-1 used stride s1s_1. So the layer-2 receptive field is: R2=R1+(k21)s1=k1+(k21)s1R_2 = R_1 + (k_2 - 1) \cdot s_1 = k_1 + (k_2 - 1) s_1 The (k21)(k_2 - 1) is the "extra" layer-1 pixels beyond the center, scaled by s1s_1 to input space.
  4. General: At layer ll, the extra coverage is (kl1)(k_l - 1) in layer-l1l-1 space, which maps to (kl1)i=1l1si(k_l - 1) \prod_{i=1}^{l-1} s_i input space.

Simplification for uniform layers: If all layers have kernel kk and stride ss:

Rl=k+(k1)i=0l2si=k+(k1)sl11s1R_l = k + (k-1) \sum_{i=0}^{l-2} s^i = k + (k-1) \frac{s^{l-1} - 1}{s - 1}

For s=1s=1 (no downsampling): Rl=1+l(k1)R_l = 1 + l(k-1) (linear growth). For s=2s=2: Rl=k+(k1)(2l11)R_l = k + (k-1)(2^{l-1} - 1) (exponential growth).

Figure — Feature maps and receptive fields

Worked Examples


Common Mistakes


Feynman Explain-to-a-12-Year-Old

Recall Explain Feature Maps and Receptive Fields Like I'm 12

Imagine you have a huge poster of a beach scene. You're an art detective trying to find patterns—like "where are the umbrellas?" You can't look at the whole poster at once, so you use a magnifying glass that only shows a small square.

Feature map: You slide your magnifying glass across the poster row by row. Every time you see an umbrella-like shape, you put a checkmark on a separate piece of paper in the same position. When you're done, your paper is covered with checkmarks showing "umbrella locations." That paper is a feature map—it's the output of one "umbrella detector" filter.

Now imagine you have 100 different detectors (magnifying glasses with different colored lenses)—one for umbrellas, one for waves, one for people, etc. You get 100 different papers (feature maps), each showing where that pattern appears.

Receptive field: At first, your magnifying glass only shows a 3×3 square of the poster (tiny!). You can only detect tiny edges. Then you stack another detective on top of you: they look at your checkmark paper with their magnifying glass. Now they're combining your tiny detections into bigger patterns—maybe "this cluster of edge checkmarks forms a circle." Since they're looking at your paper (which summarized 3×3 patches), they're indirectly seeing 5×5 of the original poster. That 5×5 is their receptive field—how much of the original poster influences one of their decisions.

Add a third detective looking at the second's paper, and now they see 7×7 of the original poster. The higher up you go, the bigger the "field of view" back to the original scene. That's how CNNs understand context—low layers see pixels, high layers see objects.


Mnemonic


Connections

  • 3.4.01-Convolutional-layers: Feature maps are the outputs of convolutional layers; receptive field depends on conv parameters.
  • 3.4.02-Pooling-layers: Pooling increases receptive field via both its window size and its stride, but doesn't add learnable parameters.
  • 3.4.03-Padding-and-stride: Padding preserves spatial size; stride controls downsampling and receptive field growth rate.
  • 3.4.05-CNN-architectures: Deep architectures (ResNet, VGG) are designed to grow receptive fields efficiently while controlling parameters.
  • 3.3.02-Activation-functions: Feature maps are passed through ReLU/etc. to introduce nonlinearity.
  • 4.2.01-Object-detection: Large receptive fields are critical for detecting large objects in context.

Active Recall Flashcards

#flashcards/ai-ml

What is a feature map in a CNN?
The 2D output produced when a single convolutional filter slides across an input. It shows the spatial locations where the filter responds strongly. If you have CoutC_{\text{out}} filters, you get CoutC_{\text{out}} feature maps.
How do you calculate the spatial size of a feature map?
Hout=(H+2pk)/s+1H_{\text{out}} = \lfloor (H + 2p - k)/s \rfloor + 1, where HH is input height, pp is padding, kk is kernel size, ss is stride. Same formula for width.
What is the receptive field of a neuron in a CNN?
The region in the original input image that can influence that neuron's activation value. It grows with depth due to stacking convolutions.
How does stride affect receptive field growth?
Stride ss multiplies the receptive field expansion. Formula: Rl=Rl1+(kl1)i=1l1siR_l = R_{l-1} + (k_l - 1) \prod_{i=1}^{l-1} s_i. Stride-2 pooling causes exponential growth; stride-1 causes linear growth.
Does a pooling layer affect the receptive field, and how?
Yes. A kp×kpk_p \times k_p pool with stride sps_p expands the receptive field by (kp1)×(k_p - 1) \times (cumulative previous strides), AND its stride sps_p multiplies all future layers' expansions.
What is the receptive field of a single 3×33 \times 3 conv layer (stride 1)?
R1=3R_1 = 3 (the kernel size itself, since it looks directly at the input).
If you stack two 3×33 \times 3 convs (stride 1), what is the receptive field at layer 2?
R2=3+(31)1=5R_2 = 3 + (3-1) \cdot 1 = 5. Each layer-2 pixel sees a 5×55 \times 5 patch of the input.
Why do deeper CNNs have better context understanding?
Deeper layers have exponentially larger receptive fields (especially with pooling), so neurons "see" more of the input image—enabling recognition of large-scale patterns and spatial relationships.
What happens to feature map size with padding p=(k1)/2p = (k-1)/2 and stride 1?
The output size equals the input size (spatial dimensions preserved). Example: k=3,p=1k=3, p=1 keeps Hout=HH_{\text{out}} = H.
How does dilated convolution affect the effective kernel size and receptive field?
The effective kernel size is keff=k+(k1)(d1)k_{\text{eff}} = k + (k-1)(d-1) for dilation dd. At d=1d=1 this equals kk; larger dd inflates the receptive field without adding parameters. Example: 3×33 \times 3 with dilation 2 has effective size 5×55 \times 5.

Concept Map

produces

stack C_out filters

padding p adds border

filter reach k, stride s

floor plus 1 fencepost

each pixel traces back

region in original image

grows exponentially with depth

combine simpler features

edges then shapes then objects

one channel per filter

Conv filter slides

Feature map

3D tensor output

Input H x W

Padded H plus 2p

Output size formula

Receptive field

Deeper layers

Hierarchical understanding

Contextual meaning

Filter opinion

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Chalo ise simple tareeke se samajhte hain. Socho ek CNN ek building ki tarah hai jisme kai floors hain. Sabse pehla floor sirf chhote-chhote patches dekh sakta hai — jaise sirf edges ya lines detect karna. Aage ke floors in edges ko combine karke corners, textures, aur phir badi shapes jaise aankh ya wheel banate hain. Har layer thoda wider area dekhti hai aur higher-level concept mein sochti hai. Yaha do important cheezein hain: feature map yaani ek filter ki "opinion" — ek pura grid jo batata hai ki filter image mein kahan-kahan "fire" ho raha hai. Aur receptive field yaani original image ka kitna hissa ek single pixel ko influence kar raha hai.

Feature map ka size nikalne ke liye ek formula hai: input size H+2pH+2p mein se filter reach kk subtract karo, phir stride ss se divide karo, aur last mein +1+1 karo (kyunki positions fencepost-style count hoti hain — agar 0,1,2 positions hain to 3 outputs hote hain, 2 nahi). Jaise agar H=32,k=5,s=1,p=2H=32, k=5, s=1, p=2 ho to output bhi 32 aata hai, matlab padding 2 wala 5×55\times5 conv spatial size ko preserve kar leta hai. Aur agar layer mein CoutC_{out} filters hain to utni hi feature maps banti hain, sab ek 3D tensor mein stack ho jaati hain — har channel ek alag filter ki opinion.

Receptive field ka concept isliye zaroori hai kyunki koi bhi deep neuron input ko directly nahi dekhta — woh apni pichhli layer ko dekhta hai, jo apni pichhli ko, aur ye chain recursively expand hoti jaati hai. Formula hai Rl=Rl1+(kl1)siR_l = R_{l-1} + (k_l - 1)\cdot \prod s_i, jisme pooling layers bhi count hoti hain. Iska matlab ye hai ki jaise-jaise hum deeper jaate hain, receptive field exponentially badhta hai, jisse neuron context samajh pata hai — jaise "ye edge ek face ka part hai, koi random line nahi". Yahi baat CNN ko itna powerful banati hai image samajhne mein, kyunki woh chhoti details se lekar badi meaning tak sab hierarchy mein capture kar leta hai.

Go deeper — visual, from zero

Test yourself — Convolutional Neural Networks

Connections