Central Similarity Hashing via Hadamard matrix

Li Yuan, Tao Wang, Xiaopeng Zhang, Zequn Jie, Francis E. H. Tay, Jiashi Feng

Abstract

Existing data-dependent hashing methods usually learn hash functions from pairwise or triplet data relationships, which only capture the data similarity locally, and often suffer from low learning efficiency and low collision rate. In this work, we propose a new global similarity metric, termed as central similarity, with which the hash codes of similar data pairs are encouraged to approach a common center and those for dissimilar pairs to converge to different centers, to improve hash learning efficiency and retrieval accuracy. We principally formulate the computation of the proposed central similarity metric by introducing a new concept, i.e., hash center that refers to a set of data points scattered in the Hamming space with a sufficient mutual distance between each other. We then provide an efficient method to construct well separated hash centers by leveraging the Hadamard matrix and Bernoulli distributions. Finally, we propose the Central Similarity Quantization (CSQ) that optimizes the central similarity between data points w.r.t. their hash centers instead of optimizing the local similarity. CSQ is generic and applicable to both image and video hashing scenarios. Extensive experiments on large-scale image and video retrieval tasks demonstrate that CSQ can generate cohesive hash codes for similar data pairs and dispersed hash codes for dissimilar pairs, achieving a noticeable boost in retrieval performance, i.e. 3%-20% in mAP over the previous state-of-the-arts.

Introduction

Large-scale image and video retrieval systems rely on converting high-dimensional data into compact binary hash codes to enable efficient searching in Hamming space. Traditional "deep learning to hash" methods typically optimize for local similarity, using pairwise or triplet relationships to pull similar samples together and push dissimilar ones apart. However, these local approaches face significant challenges: high computational complexity ($O(n^2)$ or $O(n^3)$), a lack of a global perspective on data distribution, and extreme sensitivity to data imbalance, where dissimilar pairs vastly outnumber similar ones.

Methodology: Central Similarity Quantization

To overcome the limitations of local similarity, we propose Central Similarity Quantization (CSQ). Instead of comparing samples against each other, CSQ maps each data point to a globally predefined "hash center."

Global Similarity Metric

The core innovation is the shift from local to global targets. By encouraging data points to converge toward fixed centers in Hamming space, the learning process becomes more stable and efficient.

Conceptual comparison between local similarity metrics (doublet, triplet) and the proposed global central similarity.

Constructing Hash Centers

Hash centers are points in binary Hamming space designed to be as far apart as possible. We utilize two systematic construction methods:

  1. Hadamard Matrices: For hash lengths that are powers of two, rows of a Hadamard matrix provide mutually orthogonal centers, ensuring a consistent mutual distance of $K/2$ bits.
  2. Bernoulli Sampling: For arbitrary hash lengths, bits are sampled from a Bernoulli distribution, which statistically guarantees high separation between centers.

Optimization

The model is trained using a Central Similarity Loss based on Binary Cross Entropy to minimize the distance between predicted codes and their assigned centers. To bridge the gap between continuous neural network outputs and binary codes, a Quantization Loss (using a log cosh function) is employed to force outputs toward binary values.

Experimental Results

CSQ was evaluated on benchmark datasets including ImageNet, MS COCO, NUS-WIDE, UCF101, and HMDB51.

Retrieval Performance and Efficiency

CSQ achieves state-of-the-art results, notably improving mAP on ImageNet by 20% (0.851 vs. 0.652 for previous best). Furthermore, by avoiding the overhead of pair/triplet mining, CSQ reduces training complexity to $O(nm)$, resulting in a 3x to 5.5x speedup in training time compared to local similarity methods.

Visualization of the "Collapse" Effect

t-SNE visualizations demonstrate that CSQ produces highly cohesive clusters. Similar data points "collapse" tightly around their assigned centers, while dissimilar classes are clearly separated, reflecting high intra-class compactness and inter-class dispersion.

t-SNE visualizations comparing Triplet similarity, HashNet, and the proposed Central Similarity (CSQ), demonstrating superior class separation and compactness.

Conclusion

Central Similarity Quantization represents a paradigm shift in deep hashing. By replacing local pairwise comparisons with a global central similarity metric, CSQ significantly improves both retrieval accuracy and training efficiency. The use of Hadamard matrices to define optimal hash centers provides a robust mathematical foundation for creating well-separated binary representations across diverse retrieval tasks.

Summary updated

BibTeX
@inproceedings{yuan2020central,
  author = {Li Yuan and Tao Wang and Xiaopeng Zhang and Zequn Jie and Francis E. H. Tay and Jiashi Feng},
  title = {{Central Similarity Hashing via Hadamard matrix}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  doi = {10.1109/cvpr42600.2020.00315},
}
Figure