Source-linked AI summary

Hashing with binary autoencoders

Miguel Á. Carreira-Perpiñán, Ramin Raziperchikolaei

arXiv:1501.00756v1cs.LGcs.CVmath.OCstat.ML

TL;DR

Binary hashing enables efficient image search but makes hash-function learning difficult because the codes are discrete, and common relaxation-and-binarization procedures may be suboptimal. This paper optimizes a binary autoencoder with the method of auxiliary coordinates, yielding efficient binary-constrained training and hash functions that are competitive with state-of-the-art methods. The paper also identifies limits of code utilization as a standalone quality proxy.

  • Problem

    Binary hashing requires learning low-dimensional binary codes while preserving neighbors, but binary constraints make direct optimization difficult and many methods relax them before binarization.

  • Method

    The paper applies the method of auxiliary coordinates to a binary autoencoder, alternating easier encoder-decoder and code-optimization steps while respecting binary constraints.

  • Results

    The resulting linear hash functions are consistently competitive with state-of-the-art methods, including methods using nonlinear hash functions or more sophisticated hashing objectives.

  • Takeaways & Limitations

    Respecting binary constraints during optimization is feasible and can produce better hash functions despite the binary autoencoder objective not being the best retrieval objective.

  • Takeaways & Limitations

    Code utilization alone is not a reliable proxy for precision/recall because it is not directly related to distances between data vectors.

Abstract

from arXiv · show

An attractive approach for fast search in image databases is binary hashing, where each high-dimensional, real-valued image is mapped onto a low-dimensional, binary vector and the search is done in this binary space. Finding the optimal hash function is difficult because it involves binary constraints, and most approaches approximate the optimization by relaxing the constraints and then binarizing the result. Here, we focus on the binary autoencoder model, which seeks to reconstruct an image from the binary code produced by the hash function. We show that the optimization can be simplified with the method of auxiliary coordinates. This reformulates the optimization as alternating two easier steps: one that learns the encoder and decoder separately, and one that optimizes the code for each image. Image retrieval experiments, using precision/recall and a measure of code utilization, show the resulting hash function outperforms or is competitive with state-of-the-art methods for binary hashing.

1 Introduction

Binary hashing maps high-dimensional inputs to compact binary codes for efficient search, but optimizing a hash function under binary constraints is difficult. The paper uses MAC to make joint binary-constrained optimization more tractable for binary autoencoders.

  • Motivation: Binary hashing maps high-dimensional vectors to L-bit codes, reducing search from O(ND) to O(NL) when L ≪ D.Binary operations also use smaller constants, and NL bits can fit in workstation memory.
  • Optimization challenge: Most hashing methods learn a real-valued function first and binarize it afterward, which can yield a suboptimal hash function.The paper describes this relaxation-and-binarization procedure as a filter approach.
  • Method: MAC reformulates nested binary-constrained optimization into separate, easier problems without nesting.The approach is intended to reduce the complexity caused by binary constraints.
  • Contribution: The paper applies MAC to binary autoencoders and alternates optimization steps that can be efficiently implemented and parallelized.The experiments evaluate precision/recall, reconstruction error, and entropy-based code utilization.
  • Contribution: Linear hash functions optimized through the binary autoencoder are consistently competitive with state-of-the-art methods, including methods using nonlinear hash functions.The comparison includes more sophisticated hashing objectives.

2 Related work

Related hashing methods commonly learn data-dependent low-dimensional codes and then address binarization through approximate procedures. ITQ is especially close to the binary autoencoder because it optimizes rotated, quantized PCA codes but relaxes the binary constraints during optimization.

  • Data-dependent hashing: Data-dependent hashing methods learn dataset-specific hash functions through objectives defined over hash functions or binary codes.The paper focuses on unsupervised, data-dependent approaches.
  • ITQ: ITQ first obtains continuous low-dimensional PCA codes and then learns a rotation that makes them close to binary.Its hash function is a thresholded linear projection.
  • ITQ: ITQ alternates between binary-code updates and a Procrustes rotation solved in closed form using SVD.The overall ITQ optimization is described as finding a local minimum of an NP-complete problem.
  • Connection to binary autoencoders: The paper interprets ITQ as a suboptimal binary-autoencoder optimization because it relaxes the binary constraints before projecting codes back to the binary space.This contrasts with optimizing the binary constraints directly during training.

3 Our hashing models: binary autoencoder and binary factor analysis

The paper defines binary autoencoders as reconstruction models whose encoder produces binary codes, and contrasts them with binary factor analysis, which directly optimizes a decoder and binary codes. Both formulations are difficult because of their discrete constraints.

  • Autoencoder model: A continuous autoencoder composes an encoder that maps x ∈ R^D to a lower-dimensional code with a decoder that reconstructs x.The paper mainly studies least-squares objectives with linear encoders and decoders.
  • Binary autoencoder: For hashing, the encoder is h(x) = σ(Wx), producing an L-bit code with a step function and a bias threshold.W has shape R^L×(D+1), with the extra input dimension representing the bias.
  • Binary autoencoder: The binary autoencoder minimizes reconstruction error while constraining the code layer to {0, 1}^L.The resulting nonsmooth optimization is NP-complete, and existing gradients are zero nearly everywhere where they exist.
  • Binary factor analysis: Binary factor analysis optimizes a linear decoder and binary codes directly for each input pattern.Without the binary constraint, the corresponding least-squares model has PCA as its solution.
  • Binary factor analysis: Binary factor analysis can yield a hash function by fitting a binary classifier to each code bit, making it a filter approach rather than the binary autoencoder’s wrapper approach.Its binary variables are not separable, so their optimization step cannot be solved easily.

4 Optimization of BA and BFA using the method of auxiliary coordinates (MAC)

MAC reformulates binary autoencoder optimization by introducing auxiliary coordinates, alternating encoder/decoder updates with per-example binary-code optimization. A quadratic-penalty path connects BFA and BA, while finite-penalty convergence and efficient code updates make the procedure practical.

  • MAC formulation: MAC breaks the nested binary autoencoder problem into alternating optimization over the encoder and decoder and over auxiliary binary codes.The encoder uses L classification problems, the decoder uses one regression, and the code step solves N independent binary proximal problems.
  • Z step: For fixed encoder and decoder, each example’s code balances reconstruction quality against proximity to the encoder prediction.The resulting binary optimization separates across examples and can exploit parallel processing.
  • (h, f) step: For fixed codes, the encoder learns each bit separately and the decoder reconstructs the inputs from the codes.The binary mismatch objective separates across bits because the codes and predictions are binary; the decoder is a regression problem.
  • Penalty path and convergence: The quadratic-penalty objective connects BFA and BA continuously as µ ranges from 0+ to ∞, and the MAC algorithm stops at a finite µ when the codes no longer change.The finite stopping condition follows because exact h and f updates remain unchanged once the Z step is unchanged.
  • Z step: For larger code lengths, grouped alternating optimization and relaxed initialization provide practical near-global code updates, while global-optimality conditions can stop the search early.The method groups g bits, initializes from a relaxed bound-constrained quadratic program, and recognizes global minimizers when the necessary and sufficient conditions hold.
  • Penalty schedule: The practical schedule increases µ progressively and can stop early when validation precision declines, using binary-code initialization and the penalty schedule as user parameters.In practice, the algorithm usually stops after 10 to 15 iterations when parameters stop changing.

5 Measuring code utilization using entropy: effective number of bits

The paper evaluates binary hash code utilization with the entropy of the empirical code distribution, interpreting this entropy as an effective number of bits. The measure is parameter-free but should complement, not replace, neighbor-preservation metrics.

  • Definition: Code utilization is measured as the entropy S(P(h(X))) of the distribution over the 2^L binary codes assigned to the dataset.The distribution uses normalized code counts, so the measure applies whether the dataset is smaller or larger than the available code space.
  • Interpretation: The entropy ranges from 0 to min(L, log2 N), increasing as more available codes are used and their frequencies become more uniform.It is zero when all vectors share one code; it reaches L for a uniform distribution over all available codes when N ≥ 2^L, and log2 N when N < 2^L with distinct codes.
  • Interpretation: Because entropy is measured in bits, it can be interpreted as the effective number of bits Leff used by the hash-code distribution.Leff summarizes code usage induced by the hash function on the dataset.
  • Caveat: Maximum code utilization does not by itself guarantee good neighbor preservation or precision/recall.Code utilization is not directly related to distances between data vectors, and hash functions can achieve high entropy while using impractical decision-tree constructions.
  • Use in evaluation: Leff remains useful because it is independent of user parameters such as ground-truth neighborhood size and retrieved-set size.The paper reports that Leff correlates well with precision when ranking methods that share the same model and objective function.

6 Experiments

Experiments assess optimization quality, runtime, parallelism, image retrieval, and code utilization. MAC generally improves or matches competing methods, while relaxed initialization and inexpensive Z steps provide favorable optimization behavior.

  • Experiments evaluate the binary autoencoder objective, retrieval quality, runtime, parallel speedup, precision, recall, and code utilization.
  • Z-step optimization: The relaxed initialization reaches nearly the same optima as exact binary optimization, whereas warm-start initialization performs worse early in optimization.Warm-start improves later as codes change more slowly.
  • Z-step optimization: Different group sizes converge nearly to the exact-optimization result with relaxed initialization, but runtime per iteration grows exponentially with group size.This motivates the default g = 1 with relaxed initialization.
  • Parallel processing: Parallel processing shows nearly perfect training-time scaling for the CIFAR experiment with L = 16 bits.The implementation parallelizes pointwise Z updates and bitwise encoder updates across processors.
  • Image retrieval: BA generally outperforms competing methods in precision, though relative performance varies with reported set size and retrieval conditions.ITQ or SPH can approach BA in some datasets, while BFA remains competitive but consistently worse than BA.
  • Code utilization: Leff is not independently reliable as a precision indicator, but it often correlates with precision and can help select the number of bits for a database.Leff stagnates when the dataset is small relative to the 2^L available codes.
  • Code utilization: MAC consistently improves precision and code utilization over ITQ when comparing methods based on the same binary-autoencoder objective.

7 Discussion

The discussion connects ITQ to binary autoencoders and frames the proposed BA algorithm as a corrected optimization of ITQ. It also notes why autoencoders remain attractive despite retrieval-specific objectives.

  • ITQ can be viewed as a fast approximate optimization of the binary autoencoder objective using continuous relaxation, quantization, and hash-function fitting.
  • The BA algorithm is presented as a corrected version of ITQ that optimizes the binary autoencoder model more directly.
  • Retrieval-specific objectives may better match original-space and Hamming-space distances, whereas autoencoders indirectly preserve distances through manifold reconstruction.
  • Autoencoders are described as faster, easier to optimize, and more scalable to large datasets than alternatives discussed here.
  • Binary autoencoders use deterministic binary encoder and decoder mappings, making their objective discontinuous and distinguishing them from differentiable RBMs.

8 Conclusion and future work

The paper shows that respecting binary constraints during optimization is feasible and produces hash functions competitive with state-of-the-art methods. It also presents an intuitive alternating algorithm and identifies extensions to nonlinear mappings and other objectives.

  • Respecting binary constraints during optimization is feasible and leads to better hash functions competitive with the state-of-the-art.The authors note this result is encouraging despite using an autoencoder objective that is not ideal for retrieval and focusing on linear hash functions.
  • The method uses an intuitive sequence of alternating classification, regression, and binarization steps that can reuse existing code.
  • The framework can be extended to nonlinear hash and reconstruction mappings, whose potential improvement over the linear case remains open.
  • The MAC framework may apply more widely to other objective functions for constructing better hash functions.

A Global optimality conditions for binary quadratic functions

This section develops global optimality conditions for binary quadratic optimization, including necessary and sufficient tests based on the problem data and eigenvalue bounds. It also discusses when relaxed solutions can be converted into globally optimal binary solutions and the computational trade-offs of these tests.

  • Binary quadratic optimization is generally NP-hard, but global optimality conditions can be expressed using only the problem data and primal variables.The relevant data are the symmetric matrix Q and vector b.
  • A sufficient condition is λ_min e ≥ XQX e + Xb, while a necessary condition is XQX e + Xb ≤ diag(Q)e.Here λ_min is the smallest eigenvalue of Q, e is the all-ones vector, and X = diag(x).
  • Tighter global optimality conditions exist, but they are more complicated to compute.
  • For positive semidefinite Q, a binary point solves both the binary problem and its continuous relaxation exactly when XQX e + Xb ≤ 0.
  • If a relaxed optimizer x satisfies YQ(y − x) ≤ λ_min e for y = sgn(x), then y is a global optimizer of the binary problem.The sign function maps nonnegative values to 1 and negative values to −1.
  • The sufficient conditions can be combined into a computable test, and their cost is comparable to evaluating the binary autoencoder objective.The test can also terminate exhaustive enumeration when global optimality is certified.
Loading 1501.00756v1…