In deep learning, we often face a disconnect between training objectives and evaluation goals. We evaluate models using metrics like Edit Distance (ED) or Intersection over Union (IoU), yet we train them using proxy losses like Cross-Entropy or Smooth-L1 because the actual metrics are non-differentiable. This gap often prevents models from reaching their full potential.
Researchers from the Czech Technical University propose a solution: Learning Surrogates (LS). By training a neural network to act as a differentiable stand-in for complex metrics, they allow models to optimize directly for the evaluation criteria used in the real world.
The Challenge of Non-Differentiable Metrics
Many practical evaluation metrics in computer vision involve discrete or geometrically complex operations that lack gradients:
- Edit Distance (ED): Used in text recognition, it involves dynamic programming to count insertions, deletions, and substitutions.
- Rotated IoU: Calculating the overlap of rotated rectangles is non-smooth and difficult to differentiate compared to axis-aligned boxes.
- Visible Surface Discrepancy (VSD): Used in 6D pose estimation, it requires visibility tests that are inherently non-differentiable.
While hand-crafted differentiable approximations exist, they often require deep domain expertise and simplify the problem too much (e.g., assuming axis-alignment).
Methodology: Learning the Metric Space
The core innovation is learning a mapping $h_\Phi$ that embeds both the model's prediction $z$ and the ground truth $y$ into a high-dimensional space. The surrogate loss is defined as the Euclidean distance between these embeddings:
$$\hat{e}_\Phi(z, y) = \|h_\Phi(z) - h_\Phi(y)\|_2$$
By using an embedding space rather than direct scalar regression, the gradients naturally become more refined as the prediction approaches the ground truth. This method is metric-agnostic; the surrogate only needs the final scalar value of the target metric to learn, regardless of how complex that metric's internal calculation is.
Training the Surrogate
To ensure the surrogate is effective, the authors optimize it using two primary objectives:
- Accuracy: The $L_2$ distance in the embedding space must match the actual value of the target metric.
- Gradient Penalty: To ensure stable training of the target model, the magnitude of the surrogate's gradients is constrained to be close to 1, preventing gradient explosion or vanishing.
A critical component of this training is the Local-Global approximation. The surrogate is trained on a mix of globally sampled random pairs (to cover the metric space) and locally sampled data from the current model (to ensure accuracy in the model's active operating range).
Experimental Results
The researchers demonstrated that "teaching" the model the actual metric through post-tuning yields significant gains:
- Scene-Text Recognition: Using a learned surrogate for Edit Distance (LS-ED), they achieved a 39.6% relative improvement in Total Edit Distance on the ICDAR’13 dataset. Accuracy improved across all seven benchmark datasets.
- Rotated Object Detection: For rotated bounding boxes, the surrogate method (LS-IoU) improved the $F_1$ score on ICDAR’15 from 77.37% to 80.66%, outperforming standard proxy losses.
Conclusion
Learning Surrogates via Deep Embedding provides a robust framework for bridging the gap between training and evaluation. By transforming non-differentiable metrics into a differentiable embedding space, researchers can optimize models for the metrics that actually matter. While it adds some computational overhead, the ability to fine-tune pre-trained models for specific evaluation criteria makes it a powerful tool for high-performance computer vision tasks.
Summary updated