Supervised Hashing with End-to-End Binary Deep Neural Network

Dang-Khoa Le Tan, Thanh-Toan Do, Ngai-Man Cheung

Introduction

In Content-Based Image Retrieval (CBIR), the goal is to efficiently locate similar images within massive databases. While high-dimensional floating-point vectors provide rich representations, they are computationally expensive and memory-intensive. Binary hashing addresses this by mapping images to short binary strings (e.g., 32 or 64 bits), enabling rapid searches using Hamming distance.

However, training deep neural networks to produce these bits is challenging because the sign function used for binarization is non-differentiable, resulting in zero gradients that stall learning. Previous approaches often relied on "soft" approximations like sigmoid or tanh functions, which frequently lead to vanishing gradient problems, or they decoupled feature extraction from hashing, missing the benefits of joint optimization.

Architecture and Methodology

The proposed SH-E2E framework performs supervised image hashing in a truly end-to-end fashion. The architecture integrates three primary components:

  1. Feature Extractor: Utilizes a pre-trained AlexNet (up to the $fc7$ layer) to transform raw pixels into 1024-dimensional feature vectors.
  2. Dimension Reduction (DR) Layer: A fully connected layer initialized via Principal Component Analysis (PCA) to reduce dimensionality while retaining critical information.
  3. Binary Optimizer: A series of three fully connected layers designed to output the final binary codes.
The SH-E2E architecture integrates feature extraction, dimension reduction, and binary optimization into a single pipeline.

The Alternating Optimization Strategy

To overcome the non-differentiable nature of bit generation, the authors introduce an auxiliary binary variable $B$. Instead of forcing the network to output bits directly during backpropagation, they employ an alternating optimization strategy. The loss function is designed to satisfy four key objectives:

  • Similarity Preservation: Ensuring similar images have similar binary codes.
  • Binary Constraint: Minimizing the distance between the network's continuous output and the discrete binary targets.
  • Independence: Reducing redundancy by ensuring each bit provides unique information.
  • Balance: Maximizing entropy by ensuring bits are evenly distributed between 1 and -1.

During training, the model fixes the binary targets $B$ to update network weights $W$ via Stochastic Gradient Descent (SGD), then updates $B$ based on the current network state. This avoids the "soft approximation trap" and maintains healthy gradient flow.

Experimental Results

The SH-E2E model was evaluated on three standard benchmarks: MNIST (handwritten digits), Cifar10 (object categories), and SUN397 (scene recognition). Performance was measured using mean Average Precision (mAP).

mAP performance of SH-E2E compared to state-of-the-art methods across MNIST, Cifar10, and SUN397 datasets for varying bit lengths.

Key findings include:

  • Superior Retrieval Quality: SH-E2E consistently outperformed existing supervised methods such as KSH, SDH, and SH-BDNN. On the Cifar10 dataset, it surpassed the nearest competitor by 4% to 7.5% across different bit lengths.
  • High Efficiency: The model achieved near-peak performance (98% mAP) on MNIST with as few as 16 bits, demonstrating that the learned codes are exceptionally compact and descriptive.
  • Scalability: By utilizing mini-batch SGD, the framework scales effectively to large datasets, unlike methods that require loading entire similarity matrices into memory.

Conclusion

SH-E2E demonstrates that joint optimization of feature extraction and hashing layers is critical for high-performance image retrieval. By utilizing an auxiliary variable and an alternating optimization strategy, the framework bypasses the limitations of non-differentiable functions without sacrificing gradient health. While the current implementation uses AlexNet, the framework is backbone-agnostic and could potentially achieve even higher performance with modern architectures like ResNet or Vision Transformers.

Summary updated

BibTeX
@inproceedings{tan2017supervised,
  author = {Dang-Khoa Le Tan and Thanh-Toan Do and Ngai-Man Cheung},
  title = {{Supervised Hashing with End-to-End Binary Deep Neural Network}},
  booktitle = {ICIP},
  year = {2017},
  doi = {10.1109/icip.2018.8451192},
}
Figure