# Learning Deep Features for Discriminative Localization

Global average pooling lets CNNs localize objects from image labels alone

Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, Antonio Torralba · arXiv · 2015-12-14

- **Problem** Classification CNNs with fully-connected output layers lose the localization their convolutional layers show. Dropping those layers cuts parameters but was thought to cost accuracy and location cues.
- **Method** Class activation mapping, or CAM, places global average pooling before the output layer. It reads the output weights back onto the feature maps, so each location shows its part of the class score.
- **Results** With a box-selection heuristic, GoogLeNet-GAP reached 37.1% top-5 test error, compared to 34.2% for fully supervised AlexNet.

## Where localization disappears

Convolutional layers of CNNs already act as object detectors, although no object locations are given during training. That ability is lost once fully-connected layers are used for classification. Newer networks such as Network in Network and GoogLeNet drop fully-connected layers to cut parameters without giving up accuracy.

Network in Network uses global average pooling mainly as a regularizer against overfitting. The authors found that this pooling layer does more: with a small change, the network keeps its localization all the way to the final layer. That matters because localization would then come from image-level labels alone, with no box training.

## Keeping the spatial layout until the output

The key idea is to place global average pooling just before the output and read the output weights back onto the feature maps. Global average pooling collapses each feature map to one number, and the class score is a weighted sum of those numbers. Because that sum is linear, the same weights can be applied to the maps before averaging, which keeps a spatial layout.

The authors call the resulting map a class activation map (CAM), and a single forward pass yields it.

The network is built like Network in Network and GoogLeNet, with convolutional layers, then pooling, then one output layer. The output layer's weights are therefore the link between a class and the regions that drive it.

## The class activation map formula

For unit k, the global average pooling result is F\_k, the sum of its activation f\_k(x,y) over all spatial positions, written \\(F\_k = \\sum\_{x,y} f\_k(x,y)\\). The class score before softmax is \\(S\_c = \\sum\_k w\_{ck} F\_k\\), where w\_ck is the output weight of class c for unit k. Writing each F\_k as a sum over space and swapping the two sums gives \\(S\_c = \\sum\_{x,y} \\sum\_k w\_{ck} f\_k(x,y)\\).

The inner sum defines the class activation map \\(M\_c(x,y) = \\sum\_k w\_{ck} f\_k(x,y)\\) for class c. Summing M\_c over all locations gives the class score, so each location carries its own part of that score. The authors read a high value of M\_c at a location as evidence that the location drives class c.

The authors expect each unit to respond to a visual pattern inside its receptive field, so f\_k marks where that pattern is present. Upsampling M\_c to the input size gives a map over the image pixels. The softmax bias is ignored in this derivation, since the authors judge it to have little impact on classification.

## From heat map to bounding box

To turn a map into a box, the authors threshold it and keep regions above 20% of the map's maximum value. The box then covers the largest connected component of that thresholded segmentation. For top-5 evaluation this is done for each of the five highest-ranked classes.

The step is a fixed rule applied to the map, not a learned detector. For the test set the authors use a different way of choosing boxes, which the test section covers.

## Why average pooling rather than max pooling

Oquab et al. used global max pooling for weakly supervised localization, and it picks out one peak per map. The authors note that this localizes a point lying on the object's boundary rather than its full extent.

The authors argue that averaging rewards a network for activating every discriminative part, because any low part pulls the average down. A max, by contrast, ignores all low responses once one strong response exists. They present this as the intuition behind the choice, to be checked experimentally.

On ILSVRC validation, GoogLeNet-GAP reached 43.00 top-5 localization error, compared to 45.26 for GoogLeNet-GMP. Their classification top-5 errors are close, at 13.2 for GoogLeNet-GAP and 13.9 for GoogLeNet-GMP. Since classification is similar, the authors attribute the localization gap to the pooling choice.

## Classification cost of removing fully-connected layers

For each backbone the authors cut the network after a chosen convolution layer, then added a 3x3 convolution with 1024 units. They then fine-tuned on the 1.3M ILSVRC training images for 1000-way classification.

On the ILSVRC validation set, GoogLeNet-GAP scored 13.2 top-5 error, compared to 11.3 for GoogLeNet. Most drops are in the range of 1 to 2 percent, as the authors report. AlexNet is the largest loser, with 26.3 top-5 error for AlexNet-GAP compared to 19.5 for AlexNet.

To close that gap, the authors added two convolution layers before GAP, which gives AlexNet\*-GAP a top-5 error of 20.9. The GAP networks keep most of their classification accuracy, which matters because a box is only right when its class is right.

## Localization error on ILSVRC validation

The first localization check uses the ILSVRC validation set, with top-1 and top-5 localization errors. GoogLeNet-GAP reached 43.00 top-5 localization error, compared to 49.34 for the original GoogLeNet.

Backprop saliency on the original networks scored 50.55 for GoogLeNet, 51.46 for VGGnet and 52.64 for AlexNet. Each of these is above the 43.00 of CAM on GoogLeNet-GAP, so CAM gives lower error in this comparison. The authors describe the CAM advantage over backprop as large.

GoogLeNet-GAP beats GoogLeNet on localization, although GoogLeNet is better at classification. The authors suspect that GoogLeNet's 7x7 mapping resolution limits its boxes, while GoogLeNet-GAP uses 14x14. They offer this as an explanation rather than as a tested result.

## Test-set result and the box heuristic

With a box-selection heuristic, GoogLeNet-GAP reached 37.1% top-5 test error, compared to 34.2% for fully supervised AlexNet.

The authors chose this rule because it improved results on the validation set, so the 37.1% is not the plain GoogLeNet-GAP setting.

The authors acknowledge that the gap to fully supervised networks with the same architecture is still large.

## Localized crops for bird recognition

CUB-200-2011 contains 200 bird species, with 5,994 training images and 5,794 test images. Using full images and no box annotations, GoogLeNet-GAP reached 63.0% accuracy.

The authors used thresholding to find bird boxes on training and test images, then re-extracted features from the crops. Cropping lifted accuracy to 67.8%. Training with annotated bounding boxes reached 70.5%.

At an IoU threshold of 0.5, the CAM boxes locate the bird in 41.0% of images. Chance performance was 5.5%, so the localization is well above chance.

Methods that use boxes and parts score higher, for example PANDA R-CNN at 76.4%. So the 67.8% crop result shows a gain from localization, not the best number reported on this dataset.

## GAP features as generic features

The authors trained a linear SVM on the GAP outputs, which replaces the softmax weights for each new dataset. They compared this against fc7 from AlexNet and average pooling from GoogLeNet across eight scene and object benchmarks.

On SUN Attribute, GoogLeNet-GAP scored 91.98, compared to 92.05 for average-pooled GoogLeNet features. On Caltech256 the figures were 70.62 and 72.03, both well above 54.92 for AlexNet fc7.

The authors summarize GoogLeNet-GAP as competitive with GoogLeNet, even though it has fewer convolutional layers. For localization on these datasets, the authors show example maps and judge them by eye, with no score.

## Pattern discovery and question answering

For scenes, the authors trained one-vs-all linear SVMs on 4675 fully annotated images from 10 SUN scene categories. CAM then listed the objects that most often overlap the high-activation regions, such as sink and faucet for bathrooms.

For concepts, the authors used hard-negative mining from prior work to train detectors from caption text. They show top-ranked images and CAMs for concepts such as mirror in lake. For text, a weak detector trained on 350 StreetView images highlighted text without any box labels.

The authors also used localizable features in a visual question answering baseline from prior work. That baseline reached 55.89% overall accuracy on test-standard in the Open-Ended track. The highlighted regions are shown for the predicted answers, but no localization score is given.

## Class-specific units

The softmax weights rank the units for each class, so the most useful units can be shown directly. The authors segment each unit's top activation images by its receptive field, following the earlier unit-visualization work. This is done for AlexNet\*-GAP trained on ImageNet and on the Places database.

For lakeland terrier, units detecting dog face and body fur carry the weight. For living room, units detecting sofa, table and fireplace do. The authors describe the network as a bag of such class-specific units, with their combination guiding classification.

## Limitations

The headline test number depends on a box-selection rule chosen after validation experiments. The authors attribute part of GoogLeNet's weaker result to its 7x7 mapping resolution, which they did not isolate in a separate test.

Box-level localization is scored on ILSVRC and, for birds, on CUB-200-2011 with IoU. The scene, concept, text and question-answering results are shown as maps or examples, not as localization scores. The pattern discovery experiments have no train and test split, so they are not held-out evaluations. The classification drops of 1 to 2 percent are the cost of removing the fully-connected layers, and AlexNet's drop is larger.

## Paper info

- **Authors**: Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, Antonio Torralba
- **Venue**: arXiv · Preprint
- **First published**: 2015-12-14
- **Added**: 2026-11-11
- **Updated**: 2015-12-14
- **Version**: v1
- **arXiv**: 1512.04150
- **Category**: cs.CV
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1512.04150v1) · [PDF ↗](https://arxiv.org/pdf/1512.04150v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, Antonio Torralba (2015). Learning Deep Features for Discriminative Localization. arXiv:1512.04150v1. https://arxiv.org/abs/1512.04150v1

**BibTeX**

```
@misc{zhou2015learning,
  title = {{Learning Deep Features for Discriminative Localization}},
  author = {Bolei Zhou and Aditya Khosla and Agata Lapedriza and Aude Oliva and Antonio Torralba},
  year = {2015},
  eprint = {1512.04150},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1512.04150v1}
}
```

## Other paper commentary

- [V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation](https://refivu.com/en/papers/a6e119c3-3c19-41b0-afee-c1d81e538a35-v-net-fully-convolutional-neural-networks-for-volumetric.md)
- [Aggregated Residual Transformations for Deep Neural Networks](https://refivu.com/en/papers/e793fb66-bc1f-4ced-89ed-5f634b4590ea-aggregated-residual-transformations-for-deep-neural-networks.md)
- [YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors](https://refivu.com/en/papers/c2cb4858-244f-407a-916b-4d41a9df7d4f-yolov7-trainable-bag-of-freebies-sets-new-state.md)
- [A Survey on Deep Learning in Medical Image Analysis](https://refivu.com/en/papers/4d173b56-9ea6-4644-98f2-af1794e63965-a-survey-on-deep-learning-in-medical-image.md)
- [The Unreasonable Effectiveness of Deep Features as a Perceptual Metric](https://refivu.com/en/papers/7a2a39ad-a72d-46f5-b96c-8392e55b66ee-the-unreasonable-effectiveness-of-deep-features-as-a.md)
- [YOLOv4: Optimal Speed and Accuracy of Object Detection](https://refivu.com/en/papers/3320d624-7e40-4d1e-b251-49a39602a21c-yolov4-optimal-speed-and-accuracy-of-object-detection.md)
- [node2vec: Scalable Feature Learning for Networks](https://refivu.com/en/papers/dc0725e4-ec21-4d60-9363-0eac2fc69a10-node2vec-scalable-feature-learning-for-networks.md)
- [Explainable Artificial Intelligence (XAI): Concepts, Taxonomies, Opportunities and Challenges toward Responsible AI](https://refivu.com/en/papers/3f686a20-03db-4642-80bb-f85fafc1d04f-explainable-artificial-intelligence-xai-concepts-taxonomies.md)
- [Stop Explaining Black Box Machine Learning Models for High Stakes Decisions and Use Interpretable Models Instead](https://refivu.com/en/papers/96d240ca-7c32-4f79-8167-c2beafc2a38f-stop-explaining-black-box-machine-learning-models-for.md)
- [Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network](https://refivu.com/en/papers/5a2dbd66-c794-464b-9d10-02f19eeb20e7-photo-realistic-single-image-super-resolution-using-a.md)
- [UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction](https://refivu.com/en/papers/44ccc549-6643-4369-889c-f60f3d61cbf4-umap-uniform-manifold-approximation-and-projection-for.md)
- [Representation Learning: A Review and New Perspectives](https://refivu.com/en/papers/b38149f8-9f53-4406-8d25-bb93c21c4bc9-representation-learning-a-review-and-new-perspectives.md)

## Terms in this paper

- [Convolutional Neural Networks](https://refivu.com/en/terms/936419759d72-convolutional-neural-networks)
- [backpropagation](https://refivu.com/en/terms/e09284f057ac-backpropagation)
- [GoogLeNet](https://refivu.com/en/terms/50b933468e4c-googlenet)
- [global average pooling](https://refivu.com/en/terms/f70116a971b4-global-average-pooling)
- [linear SVM](https://refivu.com/en/terms/19bedf093550-linear-svm)
- [Intersection over Union (IoU)](https://refivu.com/en/terms/fd2d9ae89f7a-intersection-over-union-iou)
- [Visual Question Answering](https://refivu.com/en/terms/fc0a624b0e20-visual-question-answering)
- [Network in Network](https://refivu.com/en/terms/3dd6e1fb9645-network-in-network)
- [class activation mapping](https://refivu.com/en/terms/56b94690bdb5-class-activation-mapping)
- [thresholding](https://refivu.com/en/terms/9d6f402c6c7a-thresholding)
- [Weakly supervised object localization](https://refivu.com/en/terms/d095b4c771d5-weakly-supervised-object-localization)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/6bdcd2a6-8c81-46b4-95d2-9560f97fd427-learning-deep-features-for-discriminative-localization)
