Searching Parameterized AP Loss for Object Detection

Chenxin Tao, Zizhang Li, Xizhou Zhu, Gao Huang, Yong Liu, Jifeng Dai

In the world of object detection, there is a frustrating "gap" between how we train models and how we evaluate them. We typically train detectors using separate mathematical functions for "what" an object is (classification) and "where" it is (localization). However, we evaluate these same models using a single, complex metric called Average Precision (AP).

A new paper from researchers at Tsinghua University, SenseTime, and other institutions, titled "Searching Parameterized AP Loss for Object Detection," proposes a clever way to bridge this gap. By turning the evaluation metric itself into a searchable, differentiable loss function, they have managed to squeeze more performance out of standard detectors without altering their underlying architectures.

TL;DR

Object detectors are usually trained on separate surrogate losses for classification and localization, but evaluated on a unified metric (AP). This paper introduces Parameterized AP Loss, which uses reinforcement learning to automatically search for a differentiable approximation of the AP metric, leading to consistent performance boosts across various detection frameworks.

What Problem Does This Paper Address?

The gold standard for evaluating object detectors is Average Precision (AP). AP is a "ranking" metric—it evaluates how well a model sorts its predictions from most to least confident while checking if the bounding boxes overlap sufficiently with the ground truth.

Comparison of existing separate losses versus the proposed unified Parameterized AP Loss.

The core problem is that AP is non-differentiable. It relies on discrete steps (like the Heaviside step function) that lack gradients, meaning standard backpropagation cannot be used to optimize it directly. Consequently, researchers usually fall back on "surrogate" losses: Focal Loss or Cross Entropy for classification, and GIoU or L1 for localization.

This creates a mis-alignment. The model spends its training time minimizing two separate errors that do not perfectly represent the single metric it will ultimately be graded on. While some prior works have tried to hand-craft "differentiable AP" functions, these are often sub-optimal and require intense manual tuning.

Methods

The authors propose a three-step solution to move from "hand-crafted" to "automated" loss design:

  1. Reformulation: They first rewrite the mathematical formula for AP so that it explicitly depends on both classification scores and box coordinates.
  2. Parameterization: They replace the non-differentiable parts of the AP formula (the "steps") with a family of parameterized piecewise linear functions. These functions are continuous and differentiable, but their exact shape is controlled by a set of parameters ($\theta$).
  3. Automated Search: Instead of guessing which shape is best, they use a reinforcement learning algorithm (PPO2) to search for the optimal parameters.
The automated search pipeline using reinforcement learning to find optimal parameters for the AP loss function.

In a "bi-level optimization" loop, the system samples a set of parameters, trains a detector for one epoch (the "inner level"), and uses the resulting AP on a validation set as a "reward" to update the search policy (the "outer level"). Crucially, they also search for a gradient scale ($\lambda$) to balance the influence of the localization branch against the classification branch within this unified loss.

Datasets

The researchers conducted all their primary experiments on the COCO 2017 benchmark, the industry standard for object detection.

  • Training: 118k images.
  • Search/Proxy Task: To speed up the search, they used a subset of 113k images for training and 5k for evaluation, training for only one epoch per sample.
  • Evaluation: The final models were re-trained on the full training set and evaluated on the standard 5k "val" subset.

Key Insights and Ideas

  • Unified is Better: One of the biggest takeaways is that a single loss function capturing both sub-tasks simultaneously outperforms separate ones. It forces the model to learn the inherent trade-off between being confident in a class and being precise with a box.
  • Search Beats Intuition: The authors compared their searched functions against common mathematical substitutes like Sigmoid or Square functions. The searched functions performed vastly better, proving that human intuition is often a poor guide for high-dimensional loss landscapes.
  • Compact Search Space: By using piecewise linear functions with a fixed number of segments (they found 5 to be the "sweet spot"), they created a search space that is flexible enough to approximate AP but compact enough for RL to navigate efficiently.

Key Results

The "Parameterized AP Loss" consistently outperformed standard handcrafted losses across three very different types of detectors:

  • RetinaNet (One-stage): Improved from 39.2 AP (with Focal + GIoU) to 40.5 AP.
  • Faster R-CNN (Two-stage): Improved from 39.1 AP (with Cross Entropy + GIoU) to 42.0 AP.
  • Deformable DETR (Transformer-based): Improved from 43.8 AP to 45.3 AP.

Notably, it also outperformed other automated loss-searching methods like AutoLoss-Zero, suggesting that starting with the structure of the AP metric is more effective than searching from scratch.

Limitations and Future Work

While the results are impressive, there are a few hurdles:

  • Search Cost: Even with a "proxy task" (training for only one epoch), searching for the optimal loss requires significant GPU resources.
  • Task Specificity: The current formula is tailored specifically for object detection. Extending this to other non-differentiable metrics—like the BLEU score in machine translation—remains an open and non-trivial challenge.
  • Black Box Nature: While we know the searched loss works better, interpreting why a specific piecewise linear shape is superior to another remains difficult.

In conclusion, this paper marks a significant step toward "AutoML for Loss Functions," showing that we can stop guessing how to balance our models and let the data (and a little RL) find the optimal path for us.

Summary updated

BibTeX
@inproceedings{tao2021searching,
  author = {Chenxin Tao and Zizhang Li and Xizhou Zhu and Gao Huang and Yong Liu and Jifeng Dai},
  title = {{Searching Parameterized AP Loss for Object Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=hLTZCN7f3M-},
}
Figure