Ultralytics YOLO27: Join the waitlist.
License YOLO
Back to Ultralytics Glossary

Feature Maps

A feature map is the grid of responses a filter produces across an image, showing where its pattern appears. Covers computation, shapes, and visualization.

A feature map is the output of one filter in a convolutional neural network (CNN) layer: a 2D grid of numbers that records how strongly the filter's pattern appears at each location of its input. A convolution layer with 64 filters produces 64 feature maps, stacked into a tensor of shape channels × height × width, and that tensor becomes the next layer's input. Feature maps from early layers highlight edges, colors, and textures, and maps from deeper layers respond to object parts and whole objects. Activation map is a synonym, and the whole stacked tensor of a layer is often called its feature map as well.

How a Feature Map Is Computed#

A filter, also called a kernel, is a small grid of learned model weights, typically 3×3 for each input channel. The convolution slides it across the input, and at each position it multiplies the overlapping values element-wise and sums them, plus a bias, into one output number. High outputs mark places where the input matches the filter's pattern. The output's height and width follow from the input size, kernel size k, padding p, and stride s as floor((input + 2p - k) / s) + 1, so a 3×3 kernel with padding 1 keeps the size at stride 1 and halves it at stride 2.

The snippet below applies a vertical-edge kernel to a tiny image that is dark on the left and bright on the right.

import torch
import torch.nn.functional as F

# An 8x8 grayscale image: dark left half, bright right half, so one vertical edge
image = torch.zeros(1, 1, 8, 8)
image[..., 4:] = 1.0

# A 3x3 Sobel kernel that responds to vertical edges
kernel = torch.tensor([[-1.0, 0.0, 1.0], [-2.0, 0.0, 2.0], [-1.0, 0.0, 1.0]]).view(1, 1, 3, 3)

# Slide the kernel over the image to produce a feature map
feature_map = F.conv2d(image, kernel)

print(feature_map.shape)
print(feature_map[0, 0, 0])

It prints torch.Size([1, 1, 6, 6]) and tensor([0., 0., 4., 4., 0., 0.]). Without padding, the 8×8 image yields a 6×6 map (8 − 3 + 1 = 6), and the map is nonzero only in the two columns where the kernel straddles the edge. Trained CNNs learn many first-layer filters that behave like this Sobel kernel, alongside filters tuned to colors and textures.

Feature Maps Through a Network#

As data moves through a CNN, feature maps usually shrink in height and width and grow in channel count. Each downsampling step halves the resolution, and each position in a deeper map summarizes a larger receptive field of the original image. Detectors keep maps from several depths because the trade-off cuts both ways: a stride-8 map of a 640×640 image is an 80×80 grid fine enough to locate small objects, and a stride-32 map is a 20×20 grid whose cells each see enough of the image to recognize large ones. A feature pyramid network (FPN) fuses maps from these depths so every scale gets both precise location and high-level meaning, and the backbone that produces them is a model's main feature extraction stage.

  • Filter: The filter holds the learned weights, and the feature map is the result of applying them to one input. One filter produces one feature map per image.
  • Activation function: A function such as ReLU applied element-wise to a feature map after the convolution. The map exists both before and after it, as pre-activation and post-activation values.
  • Embeddings: An embedding is usually a 1D vector made by pooling or flattening a feature map, which keeps what the image contains and discards where. Embeddings power similarity search and clustering, and spatial feature maps feed tasks that need location, such as semantic segmentation.
  • Saliency maps: A saliency map is a single heatmap that explains one prediction, often computed from feature maps and their gradients.

Inspecting and Visualizing Feature Maps#

Plotting individual channels as grayscale images shows what each filter responds to. First-layer maps look like edge-filtered copies of the photo, and deep maps are coarse blobs over object parts. In PyTorch, a forward hook registered with register_forward_hook captures any layer's feature maps during inference. Deep layers have hundreds of channels, so explainable AI tools usually condense them into one heatmap. Grad-CAM weights each channel of a late feature map by the average gradient of a class score and sums the channels, which highlights the image regions that drove a prediction. In the nano YOLO26 model, a 640×640 image reaches the detection head as three feature maps of 64×80×80, 128×40×40, and 256×20×20, and predicting with visualize=True saves a _cam.jpg LayerCAM overlay that weights every position of those maps by its positive gradient toward each predicted class.

Explore solutions

Computer vision in sports

Computer vision in sports

Discover how Ultralytics YOLO powers sports vision with player and ball tracking, performance analytics, coaching insights, and athlete rehabilitation.
Learn more
Computer vision for aerial imagery

Computer vision for aerial imagery

Turn drone and aerial imagery into real-time insights for agriculture, aquaculture, conservation, and geospatial analysis with Ultralytics YOLO.
Learn more
Computer vision in aerospace

Computer vision in aerospace

Apply computer vision in aerospace with Ultralytics YOLO for aircraft inspection, runway FOD detection, airport ground operations, and composite defect detection.
Learn more
Computer vision in security

Computer vision in security

Protect every site with Ultralytics YOLO models. Vision AI powers perimeter monitoring, threat detection, license-plate recognition, and workplace safety.
Learn more
Computer vision in robotics

Computer vision in robotics

Power smarter machines with Ultralytics YOLO models. Vision AI in robotics drives autonomous navigation, perception, object tracking, and real-time control.
Learn more
Computer vision in logistics

Computer vision in logistics

Streamline logistics with Ultralytics YOLO models. Vision AI enables package inspection, sorting, vehicle tracking, and real-time warehouse safety monitoring.
Learn more
Computer vision in retail

Computer vision in retail

Reimagine retail with Ultralytics YOLO models. Vision AI powers inventory tracking, shelf monitoring, queue management, and smarter customer insights.
Learn more
Computer vision in healthcare

Computer vision in healthcare

Build healthcare solutions with Ultralytics YOLO models. Vision AI in healthcare powers faster medical imaging, smarter diagnostics, and patient monitoring.
Learn more
Computer vision in manufacturing

Computer vision in manufacturing

Optimize manufacturing with Ultralytics YOLO models. Vision AI drives quality control, defect detection, PPE compliance, and assembly line automation.
Learn more
Computer vision in automotive

Computer vision in automotive

Apply computer vision in automotive with Ultralytics YOLO models. Vision AI elevates road safety, driver assistance, and vehicle automation for smarter roads.
Learn more
Computer vision in agriculture

Computer vision in agriculture

Bring vision AI to smart agriculture with Ultralytics YOLO models. Power crop monitoring, livestock tracking, and precision farming for higher, smarter yields.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning