A feature map is the complete output of sliding one filter across an entire input โ a 2-D grid where each value represents how strongly that filter's specific pattern was detected at that spatial location.
What a Feature Map Represents
A high value at position \((i,j)\) in a feature map means the filter's pattern (whatever it learned to detect โ an edge, a color transition, a texture) is strongly present in the input around that location. A low or negative value means that pattern is largely absent there. Because each filter learns to detect something different, different feature maps within the same layer highlight entirely different aspects of the same input.
From Filters to Stacked Feature Maps
Each of the layer's \(C_{\text{out}}\) filters produces one feature map of shape \((H', W')\); stacking all of them together gives the layer's full output tensor, with \(C_{\text{out}}\) now playing the role of "channels" for the next layer โ exactly the same shape convention as the original input image, but now representing learned patterns instead of raw pixel color.
Diagram
Each filter independently scans the same input, producing its own feature map โ stacked together, these become the layer's multi-channel output.
Code โ Visualizing a Feature Map's Shape
import torch
import torch.nn as nn
conv = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, padding=1)
x = torch.randn(1, 3, 64, 64) # one 64x64 RGB image
output = conv(x)
print(output.shape) # torch.Size([1, 16, 64, 64]) -- 16 feature maps, each 64x64
# Each of these 16 "channels" is one filter's feature map
one_feature_map = output[0, 0] # the first filter's feature map
print(one_feature_map.shape) # torch.Size([64, 64])
Common Mistakes
- Assuming every feature map corresponds to something a human could easily interpret visually โ this is often true for early layers (edges, colors) but becomes increasingly abstract in deeper layers, where feature maps respond to complex, learned combinations of patterns with no simple visual analog.
- Confusing a "channel" in the output with a "channel" in the original input (like RGB) โ after the first layer, channels represent learned feature maps, not raw color information.
Interview Relevance
Q: "What does one value in a feature map actually represent?" How strongly that filter's learned pattern was detected at that specific spatial location in the input โ a high value means the pattern is strongly present there, a low or negative value means it's largely absent. Each filter in a layer produces its own feature map, and the full set of feature maps (stacked as channels) becomes that layer's output.
Practice Question
A convolutional layer has 128 filters and processes a batch of 8 images, each producing 32ร32 feature maps. What is the shape of this layer's complete output tensor?