The Self-Optimal-Transport Feature Transform

Daniel Shalam, Simon Korman

TL;DR

The Self-Optimal-Transport (SOT) transform is a parameterless, differentiable module that re-embeds feature sets by solving a self-matching problem via Optimal Transport. By capturing both direct similarities and "third-party agreements" between features, it consistently boosts performance in instance-specific tasks like few-shot classification and person re-identification.

What Problem Does This Paper Address?

In many machine learning tasks, such as clustering or matching, the absolute value of a feature vector is less important than how it relates to other features in the same set. Standard deep learning pipelines often use generic feature extractors that treat each item independently. This is potentially suboptimal for "instance-specific" problems where the context of the current data batch (e.g., a specific set of images to be clustered) is crucial.

While self-attention mechanisms (like Transformers) address this by allowing features to "talk" to each other, they often require heavy training and large amounts of data. The authors sought a simpler, more mathematically grounded way to "upgrade" features to be context-aware without necessarily adding millions of new parameters.

Methods

The authors propose the Self-Optimal-Transport (SOT) transform. The process works as follows:

  1. Pairwise Similarity: Given a set of $n$ features, it first computes a pairwise cosine similarity matrix $S$, which is then converted into a squared Euclidean distance matrix $D$.
  2. Optimal Transport (OT) Formulation: It treats the problem as a "fractional matching" instance. Essentially, it tries to match the set of features to itself in a way that minimizes the total distance (cost).
  3. Sinkhorn-Knopp Algorithm: To make this optimization efficient and differentiable, they use an entropy-regularized version of the OT problem. This is solved using a few iterations of the Sinkhorn-Knopp algorithm, which produces a doubly-stochastic matrix $W$.
  4. Re-embedding: The rows of this matrix $W$ become the new, transformed features.

Unlike standard attention, SOT is parameterless—it can be dropped into a pre-trained network at test time without any retraining. However, because it is differentiable, it can also be used during training to allow the backbone network to adapt to the transform.

The SOT transform pipeline: from extracted features to a transport plan matrix.

Datasets

The authors evaluated SOT across three distinct domains:

  • Unsupervised Clustering: A synthetic dataset of points on a $d$-dimensional sphere with varying levels of Gaussian noise.
  • Few-Shot Classification (FSC): Standard benchmarks including MiniImagenet, CIFAR-FS, and CUB (birds).
  • Person Re-Identification (Re-ID): Large-scale real-world datasets Market-1501 and CUHK03.

Key Insights and Ideas

  • Direct vs. Indirect Similarity: A core strength of SOT is that the new features encode more than just how similar item A is to item B. They also encode how A and B "agree" on their relationships to every other item in the set (item C, D, etc.). This "third-party" information provides a much richer representation of the data structure.
  • Probabilistic Interpretation: The output matrix $W$ has a clear meaning: the entry $w_{ij}$ represents the relative belief or probability that items $i$ and $j$ belong to the same class or cluster.
  • Equivariance: The transform is equivariant to the order of input items, meaning the result is the same regardless of how you sequence the data points.
  • Task-Aware Dimensionality: Interestingly, the dimensionality of the SOT features equals the number of items in the set ($n$). This means the "capacity" of the embedding automatically scales with the complexity of the task.
Visualizing how SOT captures direct and indirect (3rd party) similarities.

Key Results

SOT demonstrated consistent improvements across the board:

  • Few-Shot Classification: On MiniImagenet, SOT improved the state-of-the-art PTMAP-SF method, reaching 85.59% (1-shot) and 91.34% (5-shot) accuracy.
  • Clustering: Visualizations using t-SNE show that SOT significantly tightens clusters compared to raw embeddings, making them much easier for simple algorithms like k-means to separate.
  • Person Re-ID: On the CUHK03 dataset, adding SOT to the TopDBNet architecture resulted in a massive +6.8% jump in mean Average Precision (mAP).
t-SNE visualization showing the "point gathering" effect of SOT on clusters.

Limitations and Future Work

  • Fixed Output Dimension: Because the output dimension is tied to the number of input items, it can be difficult to use SOT before layers that require a fixed input size (like standard fully connected layers).
  • Transductive Nature: SOT is inherently transductive; it needs to see the whole "test set" or batch at once to work its magic. The authors suggest exploring non-transductive variants in the future.
  • Hybrid Architectures: The authors propose that future versions could include learnable parameters (similar to Transformers) to further increase modeling capacity while maintaining the geometric constraints of Optimal Transport.

Summary updated

BibTeX
@misc{shalam2022self,
  author = {Daniel Shalam and Simon Korman},
  title = {{The Self-Optimal-Transport Feature Transform}},
  year = {2022},
  eprint = {2204.03065},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.03065},
}
Figure