NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Simultaneous feature learning and hash coding with deep neural networks

Hanjiang Lai, Yan Pan, Ye Liu, Shuicheng Yan · DOI

Introduction

Large-scale image retrieval necessitates efficient indexing and search mechanisms. Hashing has emerged as a standard solution, mapping high-dimensional image data into compact binary codes that allow for rapid similarity comparisons via XOR operations. Traditionally, this process involved a disjoint two-stage pipeline: feature extraction using hand-crafted descriptors followed by a separate quantization or coding step. This paper, published in 2015, introduces a unified "one-stage" deep learning framework that simultaneously learns optimal image representations and similarity-preserving hash codes.

Problem Statement: The Gap in Two-Stage Hashing

In traditional hashing methods, feature extraction is decoupled from the hashing process. Hand-crafted features like GIST or HOG are designed to preserve Euclidean distances but are not optimized for the subsequent binary projection. Even early deep learning approaches, such as CNNH, operated in two stages—learning hash codes first and then training a network to fit them. This lack of feedback prevents features from adapting to the specific requirements of binary quantization, often leading to suboptimal retrieval performance.

Proposed Methodology

The authors propose an end-to-end supervised pipeline consisting of three core components designed to bridge the gap between feature learning and hash coding.

1. Shared Sub-Network

The architecture utilizes a shared sub-network composed of stacked convolutional layers, inspired by the "Network in Network" (NIN) design. It incorporates $1 \times 1$ convolutions to enhance representational power while maintaining efficiency. During training, this sub-network processes triplets of images—a query ($I$), a similar image ($I^+$), and a dissimilar image ($I^-$)—to ensure the learned features reside in a unified, discriminative space.

2. Divide-and-Encode Module

A significant architectural innovation is the "divide-and-encode" module. Unlike standard fully connected layers that may produce redundant bits, this module divides intermediate feature maps into $q$ distinct slices, where $q$ corresponds to the target bit length. Each slice is responsible for generating a single bit, encouraging independence and reducing redundancy across the hash code.

Overview of the proposed deep hashing architecture, featuring the shared sub-network, divide-and-encode module, and triplet ranking loss.

3. Triplet Ranking Loss and Differentiable Quantization

The model is optimized using a triplet ranking loss, which enforces a relative distance constraint: the distance between the query and the similar image must be smaller than the distance between the query and the dissimilar image by a predefined margin. To handle the non-differentiable nature of discrete binary bits, the authors employ a sigmoid activation followed by a custom piece-wise threshold function, pushing values toward 0 or 1 during the backward pass.

Experimental Evaluation

The framework was evaluated on three benchmark datasets: SVHN, CIFAR-10, and NUS-WIDE.

Key Results

The proposed method demonstrated state-of-the-art performance across all metrics:

  • Superiority over Hand-crafted Features: On the SVHN dataset, the Mean Average Precision (MAP) increased from approximately 0.58 (using the KSH baseline) to over 0.89.
  • Outperforming Two-Stage Deep Hashing: The model consistently outperformed CNNH, achieving a relative improvement of 9% to 14% on CIFAR-10 and NUS-WIDE.
  • Architectural Efficiency: Empirical tests confirmed that the "divide-and-encode" strategy is more effective than standard fully connected layers in producing informative, non-redundant bits.
Performance comparison on the CIFAR-10 dataset showing (a) Precision within Hamming distance <= 2, (b) Precision-Recall curves, and (c) Precision at top-K returned images.

Conclusion

By integrating feature learning and hash coding into a single differentiable framework, this work marked a paradigm shift in image retrieval. The combination of triplet-based supervision and the divide-and-encode module allows the network to learn representations that are inherently robust to quantization. While challenges such as efficient triplet mining and scaling to extremely long codes remain, this "one-stage" approach set a new standard for large-scale visual search.

Summary updated

BibTeX
@inproceedings{lai2015simultaneous,
  author = {Hanjiang Lai and Yan Pan and Ye Liu and Shuicheng Yan},
  title = {{Simultaneous feature learning and hash coding with deep neural networks}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2015},
  doi = {10.1109/cvpr.2015.7298947},
}
Figure