Generalized Sum Pooling for Metric Learning

Yeti Z. Gürbüz, Ozan Sener, A. Aydın Alatan · DOI

Deep Metric Learning (DML) aims to map images into an embedding space where semantic similarity corresponds to geometric proximity. For years, Global Average Pooling (GAP) has been the standard architectural choice for aggregating spatial feature maps into a single vector. While simple and effective, GAP treats every pixel equally, inadvertently incorporating "nuisance" information—such as background textures or irrelevant objects—into the final representation.

A recent paper from ICCV 2023, "Generalized Sum Pooling for Metric Learning," introduces Generalized Sum Pooling (GSP). This learnable alternative uses optimal transport to automatically select and weight discriminative features while discarding background noise, significantly improving performance across major benchmarks.

The Problem with Global Average Pooling

Standard CNNs produce a grid of feature vectors. GAP averages this entire grid, assuming each pixel represents a semantic entity (e.g., "tireness" or "windshieldness"). However, in real-world images, many pixels represent irrelevant background elements like grass or sky. Averaging these "nuisance variables" pollutes the final embedding, making it harder for the model to distinguish between classes that share similar backgrounds.

Methods: Learning to Select Features

The GSP layer replaces the blunt averaging of GAP with a more selective, differentiable optimization process.

Overview of the Generalized Sum Pooling (GSP) architecture, illustrating the flow from feature extraction to attribute-weighted pooling and the zero-shot prediction loss.

The core components of GSP include:

  1. Trainable Prototypes: The layer maintains a set of learnable vectors ($\omega$) representing ideal discriminative features or "attributes."
  2. Optimal Transport (OT): GSP solves an entropy-smoothed optimal transport problem to decide which image features ($f_i$) are important. Features close to the prototypes receive high weights, while distant "nuisance" features are assigned to a residual category and effectively ignored.
  3. Differentiable Optimization: The authors derive analytical gradients for this OT problem, allowing GSP to be a drop-in, efficient replacement for GAP that adds less than 6% to inference time.
  4. Cross-batch Zero-shot Regularization ($L_{ZS}$): To ensure prototypes learn generalizable attributes rather than class-specific noise, a meta-learning loss is introduced. The model must predict label embeddings for one half of a batch using attribute weights learned from the other half (containing disjoint classes).

Evaluation and Results

The authors evaluated GSP on standard DML benchmarks (CUB-2011, Cars196, SOP, and In-shop Clothes Retrieval) and a custom Cifar Collage dataset designed to test robustness against noisy backgrounds.

Robustness to Background Noise

The Cifar Collage dataset places target objects within complex, shared backgrounds. This setup directly tests the model's ability to isolate relevant features.

Evaluation results on the Cifar Collage dataset, showing that GSP significantly outperforms GAP baselines in handling noisy backgrounds.

As shown in the results, GSP provides a massive performance boost over GAP in these challenging scenarios. Across standard benchmarks, GSP consistently improved Mean Average Precision at R (MAP@R) by approximately 1 percentage point. When combined with advanced techniques like Cross-Batch Memory (XBM), it achieved new state-of-the-art results, pushing performance up to 2% higher.

Key Insights

  • Theoretical Foundation: The authors prove that GAP is a special case of GSP (where the mass $\mu = 1$), establishing GSP as a true generalization.
  • Efficiency: By avoiding iterative OT solvers in favor of a closed-form gradient expression, the layer remains highly efficient for real-world deployment.
  • Semantic Attribute Learning: The $L_{ZS}$ loss enables the model to learn meaningful semantic attributes (like "wing" or "beak") without requiring expensive, manually-annotated attribute masks.

Conclusion

Generalized Sum Pooling offers a principled way to move beyond the limitations of simple averaging in metric learning. By treating pooling as a feature selection problem solved via optimal transport, GSP allows networks to focus on what truly matters in an image, leading to more robust and discriminative embeddings.

Paper Citation: Yeti Z. Gürbüz, Ozan Şener, and A. Aydın Alatan. "Generalized Sum Pooling for Metric Learning." Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2023.

Summary updated

BibTeX
@misc{gurbuz2023generalized,
  author = {Yeti Z. Gürbüz and Ozan Sener and A. Aydın Alatan},
  title = {{Generalized Sum Pooling for Metric Learning}},
  year = {2023},
  eprint = {2308.09228},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.09228},
}
Figure