Conditional Similarity Networks

Andreas Veit, Serge J. Belongie, Theofanis Karaletsos · DOI

Abstract

What makes images similar? To measure the similarity between images, they are typically embedded in a feature-vector space, in which their distance preserve the relative dissimilarity. However, when learning such similarity embeddings the simplifying assumption is commonly made that images are only compared to one unique measure of similarity. A main reason for this is that contradicting notions of similarities cannot be captured in a single space. To address this shortcoming, we propose Conditional Similarity Networks (CSNs) that learn embeddings differentiated into semantically distinct subspaces that capture the different notions of similarities. CSNs jointly learn a disentangled embedding where features for different similarities are encoded in separate dimensions as well as masks that select and reweight relevant dimensions to induce a subspace that encodes a specific similarity notion. We show that our approach learns interpretable image representations with visually relevant semantic subspaces. Further, when evaluating on triplet questions from multiple similarity notions our model even outperforms the accuracy obtained by training individual specialized networks for each notion separately.

Introduction

In computer vision, similarity is traditionally treated as a monolithic concept: Image A is either similar to Image B or it is not. However, real-world objects possess multiple attributes that can serve as the basis for comparison. For instance, a red sneaker is similar to a red t-shirt in terms of color, but similar to a blue sandal in terms of category.

Standard "Triplet Networks" attempt to force these often contradictory notions of similarity into a single distance metric. This creates a "tug-of-war" during training, where the model is simultaneously pressured to pull the sneaker toward the t-shirt (for color) and push it away (for category). The result is often a compromised feature space that fails to represent any specific attribute effectively. The authors aim to create a model that can handle these multiple, often contradictory, definitions of similarity simultaneously.

Methods: Conditional Similarity Networks

To resolve these conflicts, the authors introduce Conditional Similarity Networks (CSNs). The core idea is to learn a single, disentangled embedding space where different dimensions represent different semantic attributes.

The CSN architecture: Images are passed through a CNN to create a disentangled embedding. A conditional mask then selects a specific subspace to measure similarity for a given attribute.

The architecture consists of three main components:

  1. Disentangled Embedding: A CNN backbone maps images into a high-dimensional space where different dimensions are encouraged to encode features for specific notions of similarity (e.g., color vs. shape).
  2. Conditional Masking: For each similarity notion, the model learns a unique mask—a vector of weights that corresponds to the embedding dimensions.
  3. Subspace Selection: When a query is made under a specific condition (e.g., "compare by color"), the model applies the corresponding mask via element-wise multiplication. This effectively "shuts off" irrelevant dimensions, focusing the distance calculation on the relevant subspace.

The entire system is trained end-to-end using a modified triplet loss with $L_1$ regularization on the masks to promote sparsity and distinctiveness between subspaces.

Experiments and Results

The model was evaluated on two primary datasets: the Fonts Dataset (3.1 million images) and Zappos50k (50,000 shoe images). On Zappos50k, which includes attributes like shoe type, gender, heel height, and closing mechanism, the CSN achieved a triplet prediction error rate of 10.73%, significantly outperforming the 23.72% error rate of a standard Triplet Network.

Visualization of the learned subspaces on the Fonts dataset. The same set of images is clustered differently when embedded according to character type (left) versus font style (right).

Notably, the CSN even outperformed a set of specialized networks trained individually for each attribute (11.35% error). This suggests that joint training allows the model to learn more robust underlying visual features that are shared across different similarity notions. Furthermore, CSNs preserved the quality of convolutional filters better than standard networks when faced with conflicting similarity tasks.

Conclusion

Conditional Similarity Networks provide a flexible framework for handling multiple, potentially conflicting definitions of image similarity. By learning to mask a shared embedding space, CSNs achieve state-of-the-art performance while maintaining interpretability. Future work may focus on discovering these similarity subspaces in an unsupervised manner, removing the need for explicit attribute labels during training.

Summary updated

BibTeX
@misc{veit2016conditional,
  author = {Andreas Veit and Serge J. Belongie and Theofanis Karaletsos},
  title = {{Conditional Similarity Networks}},
  year = {2016},
  eprint = {1603.07810},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1603.07810},
}
Figure