AI Glossary / AI and machine learning / Intermediate
Class activation mapping
Definition
Class activation mapping, or CAM, is a technique that highlights image regions contributing to a particular class score in certain convolutional neural networks. It produces a coarse visual map linking a classification to spatial features in the image.
What it means
An image classifier may label a photograph as containing a dog without telling the viewer which part of the photograph influenced that decision. CAM adds a visual clue by combining the network's feature maps with weights associated with the selected class.
The map is class-specific. A single image can produce different maps when the analyst asks about different classes. Bright areas indicate stronger contributions under the chosen display convention, not a measured probability that each pixel belongs to an object.
For a business team, this can be a useful diagnostic aid. A defect classifier focusing on a label sticker rather than the product deserves investigation. A convincing heatmap, however, is not proof that the model has learned the intended concept.
How it works
The original CAM arrangement uses spatial feature maps followed by global average pooling and a linear classification layer. For a selected class, the method weights the feature maps using that class's classifier weights and adds them together.
The resulting map is enlarged to overlay the input image. Because the underlying features have lower spatial resolution, the display is usually coarse.
Related methods, such as Grad-CAM, use a different construction and support other architectural settings. Reports should identify the actual method. Calling every colored model overlay CAM hides important differences in what was calculated.
Three practical examples
- A manufacturer reviews whether a packaging classifier emphasizes damage or an unrelated printed code.
- A wildlife-image project examines class-specific maps when its model confuses an animal with background vegetation.
- A document-imaging team investigates whether a form classifier relies mainly on a logo rather than the form's content.
Think of it this way
Think of a reviewer using a highlighter to mark the parts of a photograph relevant to a label.
The analogy stops before explanation. A human reviewer can explain intentions and consider alternatives. CAM visualizes a particular computation in a network; its colors are not the model's verbal reasoning, and they do not show every influence on its decision.
Worked example
Combining two simplified feature maps
Suppose an invented classifier has two relevant feature maps. At one location, their activations are 3 and 1. For the selected class, their weights are 2 and minus 1. The weighted contribution at that location is 2 times 3 minus 1 times 1, which equals 5.
At another location, the activations are 1 and 4. Using the same weights gives 2 times 1 minus 1 times 4, or minus 2. The first location contributes more positively to this class score in the simplified calculation.
Displaying the map may involve resizing, normalization or treatment of negative values. Those choices change the picture's appearance and should be documented. Neither value is a pixel-level confidence percentage.
The analyst can then test a hypothesis suggested by the display, such as whether changing a background label changes predictions. The map identifies something worth examining; the follow-up test provides stronger evidence about dependence.
Illustrative case study
A fictional factory trains an image classifier to distinguish intact and damaged cartons. Reviewers notice that CAM overlays often emphasize a colored sticker visible on damaged examples.
The team discovers that inspectors used the sticker after identifying damage, so it accidentally became an easy shortcut in the training photographs. They collect images with sticker placement separated from damage status and assess a revised model on that collection.
The heatmap helped uncover a data problem. The decision to deploy still depends on measured errors across realistic cartons and lighting conditions. The team does not treat an improved-looking overlay as a substitute for those tests.
Common misconceptions and mistakes
- Reading heatmap color as object probability: the map represents class-related activation contributions.
- Assuming CAM works unchanged with every architecture: the original method has architectural requirements.
- Treating a highlighted region as complete causal proof: controlled tests are still valuable.
- Comparing images with separately normalized color scales without checking the display settings: brightness can be misleading.
Business use
CAM can support model review, dataset investigation and communication between technical teams and domain specialists. Its strongest business use is often generating concrete questions about shortcuts and failure cases.
Keep the input image, selected class, model version and visualization settings together. Review both correct and incorrect predictions. An attractive example selected from a presentation gives little information about reliability across the actual workload.
People also ask
Is CAM the same as image segmentation?
No. Segmentation assigns labels to pixels; CAM supplies a coarse class-related map.
Is Grad-CAM identical to CAM?
No. It is a related method with a different calculation.
Can a correct prediction have a misleading map?
A prediction may be correct while relying on an undesirable shortcut, so both need investigation.
Check your understanding
A heatmap highlights a shipping sticker in images classified as damaged. What should the team do next?
Answer: Test whether the model relies on that sticker by using suitable controlled examples. Do not assume either that the sticker proves damage or that the heatmap alone establishes the whole mechanism.
Related terms
- Convolutional neural network
- Feature map
- global average pooling
- Grad-CAM
- shortcut learning
Learn next
Read feature map and shortcut learning. Review several correctly and incorrectly classified images with a domain expert, then design one controlled test of a suspected shortcut.
More in AI and machine learning
- Circuit (neural network) - In neural-network interpretability, a circuit is a collection of internal components and connections that work together to produce a particular behavior.
- Circular analysis - Circular analysis occurs when information used to select a pattern also enters the analysis presented as independent evidence for that pattern, without a...
- Class - In classification, a class is one of the categories a model can assign to an item, such as spam, billing or delivery for incoming emails.
- Classification - Classification is the task of assigning items to predefined categories, such as sorting emails into spam or not spam, using patterns learned from labeled...
- Classification model - A classification model is a model that sorts items into predefined categories, such as spam or not spam, by learning the patterns that separate the classes...
- Classification threshold - A classification threshold is the cut-off that turns a model's probability score into a decision, such as flagging every customer scored 0.7 or higher as a...
Sources
Zhou and colleagues, Learning Deep Features for Discriminative Localization: https://openaccess.thecvf.com/content_cvpr_2016/papers/Zhou_Learning_Deep_Features_CVPR_2016_paper.pdf; author preprint https://arxiv.org/abs/1512.04150. Primary research excerpts consulted. Examples and arithmetic are original. The CAM architecture and weighted feature-map formula were checked in Zhou et al., section 2, author preprint: https://arxiv.org/pdf/1512.04150.
Previous: Class Next: Class-based n-gram