SoDeep: A Sorting Deep Net to Learn Ranking Loss Surrogates.

Martin Engilberge, Louis Chevallier, Patrick Pérez, Matthieu Cord

Abstract

Several tasks in machine learning are evaluated using non-differentiable metrics such as mean average precision or Spearman correlation. However, their non-differentiability prevents from using them as objective functions in a learning framework. Surrogate and relaxation methods exist but tend to be specific to a given metric. In the present work, we introduce a new method to learn approximations of such non-differentiable objective functions. Our approach is based on a deep architecture that approximates the sorting of arbitrary sets of scores. It is trained virtually for free using synthetic data. This sorting deep (SoDeep) net can then be combined in a plug-and-play manner with existing deep architectures. We demonstrate the interest of our approach in three different tasks that require ranking: Cross-modal text-image retrieval, multi-label image classification and visual memorability ranking. Our approach yields very competitive results on these three tasks, which validates the merit and the flexibility of SoDeep as a proxy for sorting operation in ranking-based losses.

Introduction

In machine learning, a significant gap often exists between training objectives and evaluation metrics. While models are frequently evaluated using ranking-based metrics—such as Recall@K for retrieval or Spearman correlation for regression—they are rarely trained on them directly. The primary obstacle is that the sorting operation is non-differentiable. Small changes in a model's output scores may result in zero change in rank or sudden discrete jumps, creating a "staircase" function with gradients that are either zero or undefined. Consequently, researchers typically rely on surrogate losses like triplet loss or cross-entropy, which only approximately align with the final ranking goals.

The SoDeep Framework

The authors propose SoDeep (Sorting Deep net), a standalone neural network designed to learn a smooth, differentiable approximation of the sorting function.

Architecture and Training

The framework introduces a "sorter" network, $\Theta_B$, which takes a vector of scores $y$ and outputs predicted ranks $\hat{r}$. Two main architectures were explored:

  • Bi-LSTM: A recurrent network that processes the entire sequence of scores. Since ranking is a global property—an item's rank depends on all other scores in the set—the Bi-LSTM is well-suited to capture these dependencies.
  • CNN: A convolutional approach designed to mimic local comparison algorithms.
Overview of the SoDeep framework showing the integration of the sorting network $\Theta_B$ to produce differentiable ranks.

A key advantage of SoDeep is that it is trained using synthetic data. By generating millions of random vectors and calculating their ground-truth ranks, the sorter learns to minimize the $L_1$ distance between predicted and actual ranks. Once trained, the SoDeep module is frozen and integrated into a task-specific pipeline.

Plug-and-Play Integration

During training of a target task (e.g., image classification), the task network produces scores which are then passed through the frozen SoDeep module. This produces differentiable ranks, allowing gradients from rank-based loss functions to flow back through the sorter to update the task network's parameters ($\Theta_A$).

Experimental Evaluation

The approach was validated across three distinct tasks:

  1. Visual Memorability (LaMem): Predicting image memorability, evaluated via Spearman correlation.
  2. Multi-label Classification (PASCAL VOC 2007): Evaluated via mean Average Precision (mAP).
  3. Cross-modal Retrieval (MS-COCO): Image-to-text retrieval, evaluated via Recall@K.

Key Results and Insights

SoDeep demonstrated strong performance across all benchmarks, often surpassing state-of-the-art methods or standard baselines.

  • Memorability: On LaMem, SoDeep achieved a Spearman correlation of 49.4, outperforming the previous best of 48.8 and significantly beating Mean Squared Error (MSE) baselines.
  • Retrieval: On MS-COCO, Recall@1 improved from 69.8 to 71.5 compared to similar architectures using traditional losses.
  • Classification: mAP on VOC 2007 improved by 0.8 points over standard soft-margin losses.
Comparison of Average Precision on test set over training epochs for different sorter architectures and loss functions.

The experiments revealed that the Bi-LSTM sorter consistently outperformed the CNN version, confirming that global context is vital for accurate ranking. Furthermore, because the sorter is trained on numerical distributions rather than specific image features, it is inherently task-agnostic and universal.

Discussion and Limitations

While effective, SoDeep faces some challenges. Ranking is typically performed within a training batch; if the batch size is too small, the local ranks may not represent the global distribution, affecting metrics like Recall@K. Additionally, there can be a distribution shift between synthetic training scores and the actual scores from a task network. The authors suggest using alignment techniques or constrained output functions (like cosine similarity) to mitigate this. Despite these considerations, SoDeep provides a flexible, "plug-and-play" solution for optimizing non-differentiable ranking metrics in deep learning.

Summary updated

BibTeX
@inproceedings{engilberge2019sodeep,
  author = {Martin Engilberge and Louis Chevallier and Patrick Pérez and Matthieu Cord},
  title = {{SoDeep: A Sorting Deep Net to Learn Ranking Loss Surrogates.}},
  booktitle = {CVPR},
  year = {2019},
  url = {https://openreview.net/forum?id=S7YE6Czxupr},
}
Figure