Hadamard Matrix Guided Online Hashing

Mingbao Lin, Rongrong Ji, Hong Liu, Xiaoshuai Sun, Shen Chen, Qi Tian

TL;DR

Hadamard Matrix Guided Online Hashing (HMOH) simplifies supervised online hashing by using the columns of a Hadamard matrix as pre-defined target codes. By transforming the hashing problem into a set of independent binary classification tasks and employing an ensemble strategy, HMOH achieves superior retrieval accuracy and training efficiency on streaming data compared to existing state-of-the-art methods.

What Problem Does This Paper Address?

In the era of visual big data, image hashing is essential for fast retrieval. However, most hashing methods are "one-off," meaning they train on a static dataset. Online hashing is required for dynamic scenarios where data arrives in a continuous stream.

The core challenge in online hashing is balancing learning timeliness (speed) and model accuracy. Existing supervised methods often struggle with two issues:

  1. Optimization Complexity: They impose "strong constraints" (like orthogonality or similarity preservation) that are mathematically difficult to satisfy directly. Researchers often "relax" these constraints during optimization, which leads to significant accuracy drops.
  2. Training Burden: Many methods require large batches of data to update effectively, increasing computational overhead and slowing down the system.

Methods

The authors propose HMOH, which sidesteps complex optimization by providing the model with "perfect" target codes from the start.

  • Hadamard Matrix Guidance: The key innovation is using a Hadamard matrix—a square matrix with entries of +1 or -1 where every row and column is orthogonal. The authors assign a unique column of this matrix as the "target code" for each class label. These codes naturally possess the ideal properties of hash codes: they are balanced (equal numbers of +1s and -1s) and maximally distinct (orthogonal).
  • LSH Alignment: Since the size of a Hadamard matrix is restricted to powers of two, the authors use Locality Sensitive Hashing (LSH) to project these high-dimensional target codes into the desired bit length (e.g., 32 or 64 bits) while preserving their distinctiveness.
  • Hashing as Classification: Instead of complex regression, HMOH treats the learning of hash functions as a series of simple binary classification problems. As shown in Figure 2, a classifier (right) is much more effective at finding a hyperplane to separate discrete binary data than traditional linear regression (left).
  • Multi-label Fusion: For images with multiple labels, the authors introduce a "majority principle" to fuse multiple Hadamard columns into one target code, and a "balancedness principle" to resolve ties, ensuring the resulting codes remain high-quality.
  • Ensemble Learning: To prevent the model from "forgetting" past data as it updates on new streaming batches, HMOH uses an ensemble strategy. It maintains a weighted average of models learned at every time step, which integrates knowledge across the entire data stream.
Figure 2
The HMOH Framework
Figure 1: The HMOH framework. (a) Streaming data arrives. (b) Data is assigned target codes from a Hadamard matrix. (c) Independent binary classifiers are trained to predict each bit.

Datasets

The authors evaluated HMOH on four widely-used benchmarks:

  • CIFAR-10: 60,000 images across 10 classes.
  • Places205: A large-scale scene recognition dataset (2.5 million images, 205 categories).
  • MNIST: 70,000 handwritten digit images.
  • NUS-WIDE: A multi-label dataset containing nearly 187,000 images annotated with 81 concepts.

Key Insights and Ideas

  • Pre-defined Targets: The "aha moment" is realizing that we don't need to learn the binary codes and the hash functions simultaneously. By using the Hadamard matrix, we can define optimal codes mathematically and then simply train the model to map images to those targets.
  • Classification over Regression: The paper demonstrates that treating hashing as a classification task is inherently more robust for binary outputs. Regression attempts to fit a line through points, which is ill-suited for discrete +1/-1 values and leads to higher quantization errors.
  • The Power of Orthogonality: By ensuring target codes are orthogonal, the model is forced to learn features that are maximally discriminative, reducing the likelihood of different classes being confused in the Hamming space.

Key Results

HMOH consistently outperformed state-of-the-art (SOTA) methods like MIHash and BSODH across all datasets and bit lengths.

  • Accuracy Gains: On CIFAR-10, HMOH achieved an average mAP (mean Average Precision) increase of 7.48% over the best baseline. In low-bit scenarios (e.g., 8-bit), the improvement was even more dramatic.
  • Efficiency: HMOH is significantly faster to train. For example, on CIFAR-10, it took only 9.29 seconds to process the stream, compared to 120.10 seconds for MIHash.
  • Multi-label Performance: On the complex NUS-WIDE dataset, HMOH maintained its lead, proving that the "majority principle" for code fusion works effectively in real-world multi-label scenarios.

Limitations and Future Work

  • Code Length Saturation: The authors observed that performance sometimes plateaus or slightly decreases when moving to very long code lengths (e.g., 256 or 512 bits), likely due to increased redundancy in the target codes.
  • Ensemble Weights: Currently, the ensemble strategy uses equal weights for all time steps ($\pi^t = 1/T$). Future work could explore dynamic weighting schemes that prioritize more recent or more informative data batches.
  • Kernel Selection: While the RBF kernel was used effectively here, the performance of online hashing is often sensitive to kernel parameters, suggesting a need for more automated parameter tuning in streaming environments.

Summary updated

BibTeX
@article{lin2020hadamard,
  author = {Mingbao Lin and Rongrong Ji and Hong Liu and Xiaoshuai Sun and Shen Chen and Qi Tian},
  title = {{Hadamard Matrix Guided Online Hashing}},
  journal = {Int. J. Comput. Vis.},
  year = {2020},
  url = {https://openreview.net/forum?id=gM8sX8ocJ7},
}
Figure