Anthony Bourrier

Florent Perronnin

Rémi Gribonval

Patrick Pérez

Hervé Jégou

Explicit embeddings for nearest neighbor search with Mercer kernels

Introduction

This paper tackles the problem of nearest neighbor (NN) search. Let Ω be a set supplied with a distance d and X = {x 1 , . . . , x L } be a database of elements of Ω. Given a new element q ∈ Ω, typically called a query, a nearest neighbor of q in X is a solution of the problem argmin x∈X d(q, x).

(

) 1
Such a problem arises in applications such as image search [START_REF] Sivic | Video Google: A text retrieval approach to object matching in videos[END_REF][START_REF] Torralba | Small codes and large databases for recognition[END_REF] and classification [START_REF] Grauman | The pyramid match kernel: Discriminative classification with sets of image features[END_REF][START_REF] Boiman | In defense of nearest neighbor based image classification[END_REF][START_REF] Deng | ImageNet: A Large-Scale Hierarchical Image Database[END_REF][START_REF] Perronnin | Large-scale image categorization with explicit data embedding[END_REF]. In such practical scenarii, one is usually interested in computing not only the nearest neighbor of a query but its k nearest neighbors. In this paper, we consider the case where we only seek the nearest neighbor of a query for simplicity, but the contributions described here can be easily extended to the case where one searches for several nearest neighbors of a query.

When the distance d is costly to compute and/or when L is large, it is necessary to rely on approximate nearest neighbor (ANN) schemes. These schemes typically rely on the computation of small-dimensional As opposed as the existing implicit hashing methods (top path), we first compute explicit vectors belonging to a Euclidean space, then apply an encoding method designed for Euclidean distances (bottom path).

signatures, which are compressed representations of the elements of Ω. The ANN search of a query can be performed at a reduced cost by computing the distances between the query and the signatures, which will typically be way faster to compute than the initial distance d.

Significant progress has been achieved on ANN search in the last two decades, in particular with the substantial contribution of the Locality Sensitive Hashing (LSH) approach [START_REF] Datar | Locality-sensitive hashing scheme based on p-stable distributions[END_REF]. Variants of this method have been developed, consisting of different types of low-dimensional signatures [START_REF] Muja | Fast approximate nearest neighbors with automatic algorithm configuration[END_REF][START_REF] Weiss | Spectral hashing[END_REF][START_REF] Jégou | Product quantization for nearest neighbor search[END_REF]. However, the aforementioned methods only consider simple metrics such as p norms, and mainly the Euclidean norm.

In this paper, we will consider the case where the distance d derives from a Mercer kernel K, which is a broad generalization of the case where the distance is Euclidean. In this case, some methods have been proposed to compute adequate signatures by analogy with LSH, such as Kernelized Locality Sensitive Hashing (KLSH) [START_REF] Kulis | Kernelized locality-sensitive hashing for scalable image search[END_REF] or Random Maximum Margin Hashing (RMMH) [START_REF] Joly | Random maximum margin hashing[END_REF]. These methods essentially aim at imitating LSH in the implicit space associated to K. Our contribution is to propose a simple alternative to these methods by exploiting the notion of explicit embedding, which consists in approximating explicitly the kernel by a finitedimensional scalar product. After this step, a standard Euclidean encoding scheme can be applied. This scheme is illustrated in Figure 1. While simple, this strategy is shown to perform surprisingly well compared to the previously mentioned hashing schemes.

The paper is divided as follows: in Section 2, we review basics on kernels and mention some explicit embedding techniques, particularly Kernel Principal Component Analysis (KPCA), which we subsequently use. Section 3 describes existing binary hashing schemes designed for Mercer kernels. In Section 4, we present the proposed method to perform ANN search. In Section 5, we describe the datasets and report the experiments comparing our method with the previously mentioned hashing schemes. Finally, the appendix describes an exact search technique which can be derived from applying KPCA to the initial vectors. Though much more computationally costly than an approximate search scheme, this method can yield computational savings in some cases.

Mercer kernels and explicit embeddings 2.1 Mercer kernels

Let us first recall standard definitions and properties of Mercer kernels [START_REF] Schölkopf | Learning with Kernels: Support Vector Machines, Regularization, Optimization and Beyond[END_REF]. A positive semi-definite (PSD) kernel on a space Ω is an application K : Ω 2 → R such that for any collection X = {x 1 , . . . , x L } of elements of Ω, the Gram matrix

K(X ) =    K(x 1 , x 1 ) . . . K(x 1 , x L ) . . . . . . K(x L , x 1 ) . . . K(x L , x L )    (2)
is symmetric semi-definite positive. For any such kernel, there exists a unique (up to isomorphism) Hilbert space H and application Ψ : Ω → H such that ∀x, y ∈ Ω,

K(x, y) = Ψ(x), Ψ(y) H , (3)
where •, • H is the scalar product of H. Space H is usually named implicit space, since it is a space which allows the implicit interpretation of the action of K as a scalar product, provided one knows the implicit function Ψ which embeds Ω into H. Usually, one does not know this function but some interesting properties can still be derived, relying on the so-called kernel trick : one does not need to explicitly know the values of Φ(x) and Φ(y) to compute their scalar product in H, since this scalar product is equal to K(x, y).

In particular, K induces a distance d K on Ω by posing

d K (x, y) = K(x, x) + K(y, y) -2K(x, y). (4)
Let's notice that if we define

S K (1) = {x ∈ Ω : K(x, x) = 1}, (5)
then for all x, y ∈ S K (1),

d K (x, y) = 2 (1 -K(x, y)) . (6)
This property ensures that when considering data X ⊂ S K (1) and a query q ∈ S K (1), the problem (1) with d = d K is equivalent to the following problem:

argmax x∈X K(q, x), (7)
that is searching for the nearest neighbor in the sense of d K is equivalent to searching for the most correlated vector in the sense of K. This constitutes a good incentive to normalize data, that is project it onto S K (1), when it is possible: it allows one to consider kernels instead of distances. This will be used in our contribution, where we will perform our experiments on normalized data. In the particular case where Ω is a compact Hausdorff space provided with a finite measure µ with support Ω, the kernel K is a Mercer kernel [START_REF] König | Eigenvalues of compact operators with applications to integral operators[END_REF], that is H = 2 (R) and for all i ∈ N, there exists λ i ∈ R and

Ψ i : Ω → R satisfying Ψ(x) = λ i Ψ i (x) ∞ i=0 , (8)
with λ i ↓ 0 and Ω Ψ i Ψ j dµ = 1 if i = j and 0 if i = j. The λ i 's and Ψ i 's are respectively the eigenvalues and the eigenfunctions of K. In this case, the embedding Ψ therefore transforms elements of Ω into squaresummable sequences. This is particularly important in order to approximate the kernel values, as we will see in the next section.

Explicit embeddings

Performing an explicit embedding consists in approximating the unknown function Ψ by an explicit function Ψ which maps Ω to the Euclidean space R E (E > 0 is the embedding dimension), and satisfying

Ψ(q), Ψ(x i ) H ≈ Ψ(q), Ψ(x i ) , (9)
where •, • is the usual scalar product in R E . Let us provide a quick review of the standard KPCA method, as well as a brief list of other embedding methods which have been proposed.

Kernel Principal Component Analysis

KPCA was introduced in [START_REF] Schölkopf | Nonlinear component analysis as a kernel eigenvalue problem[END_REF] as a way to perform explicitly Principal Component Analysis (PCA) in the implicit space H, thus being a generic way to compute a finite-dimensional embedding of the data satisfying the condition [START_REF] Grauman | The pyramid match kernel: Discriminative classification with sets of image features[END_REF]. Performing PCA on the set of vectors Ψ(Y) = {Ψ(y i )} M i=1 in implicit space H consists in projecting them onto the E-dimensional subspace V that minimizes the following mean-squared error:

M i,j=1
(K(y i , y j ) -P W Ψ(y i ), P W Ψ(y j ) H ) 2 [START_REF] He | Scalable similarity search with optimized kernel hashing[END_REF] over all E-dimensional subspaces W (P W being the orthogonal projection onto W ).

It is possible to compute explicitly this projection for any vector of the form Ψ(y) by exploiting the Gram matrix K(Y) = (K(y i , y j )) i,j=1,...M . Let us denote its E largest eigenvalues by (σ 2 i ) E i=1 and by (u i ) E i=1 the corresponding eigenvectors. Let K(y, :) be the vector [K(y, y 1 ), . . . , K(y, y M )] T . Then if (v i ) E i=1 denote the E first eigenvectors of the covariance operator of Ψ(X ), one has [START_REF] Schölkopf | Nonlinear component analysis as a kernel eigenvalue problem[END_REF]:

ϕ i (x) = P V Ψ(x), v i H = 1 σ i K(x, :), u i . (11)
This result allows us to define by PCA approximation an explicit embedding Ψ : Ω → R E such that Ψ(x) = [ϕ i (x)] E i=1 and an approximate kernel K(x, y) = Ψ(x), Ψ(y) . We therefore have

K(x, y) = P V Ψ(x), P V Ψ(y) H . ( 12
)
Note that KPCA is adaptive, that is the explicit embedding Φ it produces is learned on training data Y, and thus depends on it (as well as on the chosen E).

Other explicit embeddings

Other embedding methods have been proposed for specific kernels in a classification context. In [START_REF] Maji | Max-margin additive models for detection[END_REF], the authors describe an explicit embedding for the histogram intersection kernel, defined for x, y ∈ R n by

K(x, y) = n i=1 min(x i , y i ). (13)
In [START_REF] Vedaldi | Efficient additive kernels via explicit feature maps[END_REF][START_REF] Vedaldi | Efficient additive kernels via explicit feature maps[END_REF], the authors propose a nonadaptive (thus requiring no input data nor learning step) embedding algorithm for additive or multiplicative kernels, that is kernels defined on R n as

K(x, y) = n i=1 k(x i , y i ) or K(x, y) = n i=1 k(x i , y i ),
where k is a kernel on R.

In [START_REF] Perronnin | Large-scale image categorization with explicit data embedding[END_REF], the authors suggest applying KPCA independently in each dimension if the kernel K is additive. This yields a computational gain at the cost of a loss of precision in the embedding approximation.

As we will see, the methods we propose heavily relies on explicit embeddings. In all our experiments, we used KPCA as the embedding method, mainly because we are aiming at a generic kernel-independent method. In that sense, the KPCA has the benefit that it does not make any assumption on K other than the fact it is a Mercer kernel. Moreover, KPCA allows one to derive an embedding in R E without constraints on E, whereas for instance, [START_REF] Maji | Max-margin additive models for detection[END_REF][START_REF] Vedaldi | Efficient additive kernels via explicit feature maps[END_REF][START_REF] Perronnin | Large-scale image categorization with explicit data embedding[END_REF] require the output dimensionality to be greater than or equal to that of the initial space. Finally, KPCA yields in practice good approximations on real datasets.

ANN hashing schemes for kernels

In this section, we describe two previously existing methods developed in order to compute signatures specifically aimed at solving problem (1) when d is a Mercer kernel distance. Both methods produce binary signatures, which are then compared with respect to the Hamming distance in the signature space. Note that other methods aimed at producing small-size signatures for kernels exist, such as [START_REF] He | Scalable similarity search with optimized kernel hashing[END_REF][START_REF] Gorisse | Locality-sensitive hashing for chi2 distance. Pattern Analysis and Machine Intelligence[END_REF], but were not considered in our work because the framework presented in these papers is different from ours and closer to a classification context.

Kernelized Locality Sensitive Hashing

In LSH, a typical choice for the hash functions for n-dimensional vectors are functions of the type h : x → sign( x, r ), where r is usually chosen as a random draw with respect to a normal distribution N (0, I). Kernelized Locality Sensitive Hashing (KLSH) [START_REF] Kulis | Kernelized locality-sensitive hashing for scalable image search[END_REF] aims at imitating this Gaussian random choice in the implicit space H.

To this end, the authors select M data points

Y = {y 1 , . . . , y M } among X .
The hash functions are of the following form:

h(x) = sign M i=1 w i K(x, y i ) , (14)
where w = [w i ] M i=1 is a weight vector chosen as:

w = K(Y) -1 2 e S , (15)
where e S is a vector with Q < M entries equal to 1 and selected at random, and the others set to 0. This particular choice indeed approximates a standard Gaussian draw in the implicit space [START_REF] Kulis | Kernelized locality-sensitive hashing for scalable image search[END_REF].

Random Maximum Margin Hashing

Random Maximum Margin Hashing (RMMH) [START_REF] Joly | Random maximum margin hashing[END_REF] aims at finding hash functions of the form

h : x → sign( Ψ(x), r H + b),
where r is once again a vector of H and b is a real number. The authors express the problem of finding such hash functions as an support vector machine (SVM) problem. Each hash function is chosen as follows: an even number M of vectors y 1 , . . . , y M are randomly drawn from X and half of these vectors are labeled with label +1, the other half with label -1. The corresponding hash function is given by

h(x) = sign M i=1 α i i K(x, y i ) + b , ( 16
)
where i is the label of y i and (α i ) M i=1 and b maximize the usal C-SVM cost:

1 2 M i,j=1 i j α i α j K(y i , y j ) + C M i=1 ξ i , (17)
subject to ∀i, ξ i ≥ 0 and 1 -ξ i ≤ i   M j=1 j α j K(y i , y j ) + b   . (18)
Intuitively, this formulation finds hash functions which prevent close neighbors from having a different image by the hash function, since the hyperplane is chosen by margin maximization. This method has been presented as yielding better precision than KLSH for approximate search.

Proposed approximate search method 4.1 General description

The binary schemes described in Section 3 are implicit schemes: they aim at finding the encoding function directly as a hashing function in the implicit space H, expressing it as a function of the kernel K. Instead, the approximate scheme we propose relies on two separate steps:

B 1 B 2 B D . . . quant. quant. quant.
Figure 2: Illustration of the PQ procedure on one vector. The vector is considered as a product of D subvectors of equal length, and each subvector is quantized separately using a k-means algorithm on the database X .

1. The data is embedded in a Euclidean space R E using a function Ψ corresponding to KPCA a .

2. The signatures are computed by applying a Euclidean signature method on the vectors Ψ(x i ) in R E .

Note that at step 2, if the data is normalized with respect to the kernel K, any compression technique which aims at approximating the dot-product, the Euclidean distance or the cosine similarity could be employed. This includes among others LSH [START_REF] Charikar | Similarity estimation techniques from rounding algorithms[END_REF][START_REF] Datar | Locality-sensitive hashing scheme based on p-stable distributions[END_REF] which approximates the cosine or Spectral Hashing [START_REF] Weiss | Spectral hashing[END_REF] and Locality Sensitive Binary Code [START_REF] Raginsky | Locality-sensitive binary codes from shift-invariant kernels[END_REF] which approximate the Euclidean distance. In this section, we particularly focus on a recently proposed technique known as Product Quantization (PQ) which has been shown to be state-of-the-art for the Euclidean distance [START_REF] Jégou | Product quantization for nearest neighbor search[END_REF].

Product quantization and variations

Most of the techniques based on short signatures for ANN search consider binary codes [START_REF] Kulis | Kernelized locality-sensitive hashing for scalable image search[END_REF][START_REF] Joly | Random maximum margin hashing[END_REF][START_REF] Gong | Iterative quantization: A procrustean approach to learning binary codes[END_REF]. In [START_REF] Jégou | Product quantization for nearest neighbor search[END_REF], the authors proposed instead the PQ algorithm which produces non-binary codes allowing the estimation of Euclidean distances in the signature domain. For this purpose, a product quantizer is used to decompose the feature space into a Cartesian product of D subspaces. A given database vector x is decomposed into D subvectors of equal lengths, each of which is quantized separately using a k-means quantizer with a limited number of centroids. This number is typically set to 256 such that each subvector is quantized as a 1-byte code (8 bits) and therefore the vector is represented by a D-bytes code. This quantization is illustrated in Figure 2. The estimation of d(q, x) is done in an asymmetrical manner, i.e., the query q is not quantized to prevent it from being approximated. Computing a distance estimate requires D table look-ups and additions, which remains competitive compared with operations on binary vectors at a given signature size.

In our experiments, we also add a preprocessing step to this standard PQ framework. It is described in Section 5.2.1.

Summary of the proposed indexing and search procedure

We now summarize the whole search procedure. The offline steps are:

1. Embedding of the database:

Using KPCA requires to learn it from the data. To this end, we select M vectors at random from X and learn the embedding Ψ by KPCA. One may consider using another explicit embedding which does not require learning. Once Ψ has been determined, the vectors Ψ(x) are computed for each x ∈ X .

Encoding of the database:

PQ is learned using the vectors Ψ(X ) = { Ψ(x), x ∈ X }. Note that other Euclidean coding schemes may not require this learning step. The signatures of the vectors Ψ(x) are computed.

Given a query q, the online steps are:

1. Embedding/encoding of the query:

The embedding of the query Ψ(q) is computed. If the chosen Euclidean encoding is symmetric (like LSH), the signature of Ψ(q) needs to be computed. If it is asymmetric (like PQ), it needs not.

a Any other explicit embedding method can be used if applicable, but we used KPCA in our experiments. The distances between q (or its signature) and the database signatures are computed. The N L corresponding (approximate) nearest neighbors are identified. These are the potential (true) nearest neighbors.

Reranking of the potential nearest neighbors:

The true distances between the query and the N considered vectors are computed to rerank them to respect to the distance of interest.

Experiments

In this section, we describe the experiments performed to compare the ANN search scheme proposed in Section 4 with the methods mentioned in Section 3.

Datasets and experimental protocol

For the sake of reproducibility, we have used publicly available datasets of vectors that are large enough to evaluate the interest of ANN search techniques. The three benchmarks consist of visual descriptor extracted from real images:

• SIFT1M : This benchmark introduced in [START_REF] Jégou | Product quantization for nearest neighbor search[END_REF] consists of one million local SIFT descriptors [START_REF] Lowe | Distinctive image features from scale-invariant keypoints[END_REF] computed on patches extracted with the Hessian-Affine detector [START_REF] Mikolajczyk | A comparison of affine region detectors[END_REF].

• BIGANN [START_REF] Jégou | Searching in one billion vectors: re-rank with source coding[END_REF]: This set provides a NN ground-truth for subsets of increasing size, from one million to one billion vectors. These descriptors were extracted using the Difference of Gaussians (DoG) detector and are therefore not equivalent to those of the SIFT1M benchmark.

• Imagenet [START_REF] Deng | ImageNet: A Large-Scale Hierarchical Image Database[END_REF]: This set contains the pre-computed 1,000-dimensional bag-of-words (BOW) vectors provided with the images of the 2010 Large-Scale Visual Recognition (ILSVRC'2010). For our search problem, the larger "train" set is used as the database to be searched, the "val" set to learn the parameters, and we randomly selected a subset of 1,000 queries from the "test" set to act as queries to be processed by our methods.

Table 1 summarizes the main characteristics of the three datasets.

In our case, each of these datasets is separated into three disjoint sets: a query set, a training set and a validation set, this separation being random for SIFT1M and BIGANN which do not have such explicit prior separation of the full dataset.

For these three datasets, we are looking for the most similar vectors with respect to the χ 2 kernel, as done in related works [START_REF] Joly | Random maximum margin hashing[END_REF][START_REF] Vedaldi | Efficient additive kernels via explicit feature maps[END_REF]. The χ 2 kernel is defined on Ω = R n by

K(x, y) = K χ 2 (x, y) = n i=1 x i y i x i + y i . (19)
In our experiments, all the data vectors were 1 -normalized. This is the normalization for which K χ 2 (x, x) = 1, and thus it is the required normalization to get the equivalence between nearest neighbor and highest kernel value, as discussed in Section 4.

Dataset

SIFT1M Imagenet Pre-processing

None RR RP None RR RP Recall@1 0.17 0.15 0.19 0.04 0.04 0.05 Recall@10 0.42 0.39 0.51 0.12 0.12 0.14 Recall@100 0.75 0.74 0.85 0.30 0.33 0.37 Recall@1000 0.96 0.97 0.99 0.60 0.67 0.69

Table 2: Choice of the pre-processing: performance of KPCA+PQ (Recall@R) with no pre-processing [START_REF] Jégou | Product quantization for nearest neighbor search[END_REF], Random rotation (RR) [START_REF] Jégou | Aggregating local descriptors into a compact image representation[END_REF] and Random permutation (RP). Parameters: M = 1, 024, E = 64 and D = 8 for the two datasets considered. Averages on 10 experiments.

In the experiments we describe, the search performance is measured by the Recall@R, which measures the rate of queries for which the nearest neighbor with respect to the χ 2 kernel in input space is present among the R closest neighbors in the Euclidean signature/embedded space. Note that the higher the Recall@R, the lower the complexity of the third online step of the search procedure described in Section 4.3, because fewer vectors need to be reranked to get the true nearest neighbor.

Experiments on approximate search

Let us now discuss a particular pre-processing which has been chosen for the PQ technique in our experiments.

Pre-processing for energy balance.

Since we are applying PQ after a KPCA, the energy is not equally distributed in the embedded vectors Ψ(x i ): the first components have high energy while the last components have smaller values. This has a negative impact on PQ since the last subvectors will have less variance than the first while the k-means clustering still produces the same number of centroids for each subvector. Intuitively, one should find a way to balance energy between the subvectors so that all the quantizers have a subvector of comparable energy to encode. Note that alternatively, one could also consider using more centroids to encode subvectors with higher variance.

In [START_REF] Jégou | Aggregating local descriptors into a compact image representation[END_REF], the authors faced the same phenomenon after a regular PCA. In this context, they argue that the PQ technique is more effective if a rotation matrix is applied on the vectors produced by the PCA and prior to PQ encoding. The drawback is that the individual product quantizers partially encode the same information, since the decorrelation performed by PCA is lost.

In our contribution, we consider the use of a random permutation of the components of the vectors Ψ(x i ) as an alternative to applying a random rotation. The random permutation is cheaper to compute and it ensures that the component decorrelation achieved by KPCA is retained.

In order to choose the appropriate pre-processing for PQ, let's study the impact of three pre-processing techniques:

(i) No pre-processing is done at the output of the KPCA.

(ii) A random rotation is applied to the Ψ(x i ).

(iii) The components of the Ψ(x i ) are randomly permuted.

Table 2 shows that the choice of the pre-processing stage has an impact on the search quality in terms of Recall@R. On SIFT1M, the random permutation is clearly the best choice. On Imagenet, the difference is less clear but the random permutation still yields better results. We will therefore adopt this choice in all subsequent experiments.

Comparison with the state of the art.

We now compare the proposed coding scheme based on KPCA+PQ with the state-of-the-art techniques described earlier: KLSH [START_REF] Kulis | Kernelized locality-sensitive hashing for scalable image search[END_REF] and RMMH [START_REF] Joly | Random maximum margin hashing[END_REF]. We note that the proposed approach differs in two significant ways from KLSH and RMMH: (i) KLSH and RMMH rely on an implicit embedding while we rely on an explicit KPCA embedding.

(ii) The signatures produced in KLSH and RMMH are binary while PQ encodes an embedded vector Ψ(x i ) as a succession of bytes.

To better understand the respective impact of these two differences, we also evaluate a coding scheme based on KPCA+LSH, which performs an explicit embedding of the data (as in the first step of the proposed scheme) but performs a standard binary coding instead of PQ final encoding. Comparing this scheme with KLSH and RMMH allows one to measure exactly the gain of adding the explicit embedding step since the produced binary codes are very similar to those produce by KLSH and RMMH.

The experiments are carried out with different signature sizes (noted B in bits).We compare the encoding schemes in terms of Recall@R at a given signature size: this is a good measure of the complexity of the reranking step for a similar search cost in the signature space and signature storage cost.

The number of learning vectors for the KPCA is set to M =1; 024, so that the number of kernel computations when processing a query is limited. The same number of learning vectors is consistently used for the KLSH and RMMH algorithms, so that the variety of the encoding functions which can be built is the same. For the embedding dimension E, we set it differently depending on the scheme. For KPCA+PQ, we set E =128. For KPCA+LSH, we set E =B which led to optimal or near optimal results in preliminary experiments.

We report results for SIFT1M on Figure 4 and for Imagenet on Figure 5. We repeated all experiments 10 times, with different random draws for any step that relies on randomness. We show the average and standard deviation: selection of the M learning vectors and choice of the encoding functions. We show the average and standard deviation.

First observe that, as reported in [START_REF] Joly | Random maximum margin hashing[END_REF], RMMH outperforms KLSH on the BOW Imagenet features. However, for SIFT features, KLSH performs significantly better than RMMH. For instance, for B=128 bits, the improvement in recall@100 is on the order of 10% absolute. Second, we can see that the simple KPCA+LSH scheme outperforms KLSH andRMMH at all ranks and code sizes. This difference is significant (on the order of 10% absolute on SIFT1M for 128 bits). This shows the practical superiority of explicit embedding over implicit embedding for approximate search on these datasets. Finally, we can observe that KPCA+PQ performs significantly better than KPCA+LSH, which confirms the superiority of a non-binary encoding scheme over a binary coding scheme [START_REF] Jégou | Product quantization for nearest neighbor search[END_REF].

Overall, the improvement of KPCA+PQ with respect to KLSH and RMMH can be considerable, especially for small codes. For instance, for SIFT1M and for B = 64, the recall@100 is about 80% for KPCA+PQ while it is 20% for KLSH. For Imagenet and for the same number B of bits, the recall@1000 of RMMH is somewhat above 30% while KPCA+PQ achieves on the order of 70% (Figure 4, right plot).

Large scale experiments.

Figure 3 reports the Recall@R measured on subsets of 1M-200M SIFT descriptors taken from the BIGANN dataset. These results show that the proposed KPCA+PQ scheme can scale to very large datasets without a drastic loss in performance.

Implicit Explicit

Binary KLSH/RMMH KPCA+LSH Non-binary KPCA+PQ Table 3: Summary of the compared schemes. Experimentally, we have shown better Recall@R by replacing implicit binary schemes (KLSH/RMMH) similar to LSH by an explicit embedding followed by LSH. The Recall@R can be improved further by replacing LSH by PQ.

Conclusion

This study shows that when dealing with a distance derived from a Mercer kernel, the use of explicit embeddings can benefit approximate nearest-neighbor search. The proposed approximate scheme, despite its simplicity, performs better than other state of the art encoding methods in this framework. Performing KPCA followed by a standard binary LSH encoding yields better precision than standard methods which directly mimic binary LSH in the implicit space, thus giving a first incentive to use explicit embeddings. Furthermore, mapping the initial elements into a Euclidean space allows one to use a wide range of schemes designed for computing signatures, and especially Product Quantization, which performs way better than binary schemes at an equivalent signature size. These cases are summarized in Table 3.

Using an explicit embedding prior to an efficient Euclidean coding scheme should therefore be considered as a baseline when measuring the performance of ANN search methods with small signatures in a kernelized framework.

A.1 Error bound for the KPCA embedding

Precision bounds on the KPCA that are provided in the literature are usually probabilistic bounds on the error between the empirical eigenvalues/ eigenfunctions computed from the matrix K(X ) (denoted σ 2 i and u i in Section 2) and their continuous counterparts. Such bounds are difficult to obtain and they are not tight or require oracle knowledge about the implicit embedding [START_REF] Shawe-Taylor | On the eigenspectrum of the gram matrix and the generalization error of kernel pca[END_REF][START_REF] Braun | Accurate error bounds for the eigenvalues of the kernel matrix[END_REF].

However, it is possible to get tighter bounds for our problem by exploiting the data we consider. As shown in Section 2, KPCA is an orthogonal projection onto a subspace V in the implicit space H. The approximation error (x, y) = K(x, y) -K(x, y) can thus be written as a scalar product in the implicit space:

(x, y) = K(x, y) -K(x, y) = Ψ(x), Ψ(y) H -P V Ψ(x), P V Ψ(y) H = P V ⊥ Ψ(x), P V ⊥ Ψ(y) H , (20)
where P V ⊥ is the orthogonal projection on the subspace orthogonal to V . Let us denote

R(x) = ||P V ⊥ Ψ(x)|| H = K(x, x) -|| Ψ(x)|| 2 1 2 . ( 21
)
This quantity can be easily computed in practice. The Cauchy-Schwarz inequality provides a bound on (x, y) in terms of R(x) and R(y):

| (x, y)| ≤ R(x)R(y). (22)
This bound can be used for nearest neighbor search. Despite its simplicity, we believe it has never been used in such a context. Let us assume that we look for the nearest neighbor of a query q in the vector dataset X and let us define

x 1 = argmax x∈X K(q, x) and x1 = argmax x∈X K(q, x), (23)
that is respectively the nearest neighbor and approximate nearest neighbor of the query q. We can get a lower bound for K(q, x 1 ) by noticing:

K(q, x 1 ) ≥ K(q, x1 ) ≥ K(q, x1 ) -R(q)R(x 1 ). (24)
For any vector x ∈ X , we can get an upper bound on K(q, x):

K(q, x) ≤ K(q, x) + R(q)R(x). (25)
Combining ( 24) and ( 25), we obtain that, if for some x we have:

K(q, x) + R(q)R(x) < K(q, x1 ) -R(q)R(x 1 ), (26)
then K(q, x) < K(q, x 1 ) and x cannot be the nearest neighbor of q. The following section describes a procedure that uses this result to avoid kernel computations while still being sure to find the nearest neighbor of a query.

A.2 Exact search procedure: description and illustration

Assuming that the quantities R(x) are computed and stored while performing the embedding of all vectors in dataset X , the nearest neighbor of the query q is retrieved exactly by using the following procedure, which principle is illustrated in Figure 6: 1. Compute Ψ(q) and R(q) using Equation (11).

2. Compute K(q, x) = Ψ(q), Ψ(x) for all x ∈ X .

Find x1 = argmax

x∈X K(q, x)

4. Find all elements y ∈ X such that: K(q, x1) -R(q)R(x1) ≤ K(q, y) + R(q)R(y).

Let us denote by Y this set of vectors.

5. The true nearest neighbor of the query is x1 = argmax y∈Y K(q, y).

A.3 Complexity Analysis and Experiments

Let L be the size of the base X , E be the embedding dimension, M be the number of vectors used for KPCA, N be the cardinality of Y, C K be the cost of computing the kernel between two vectors in the initial space and C K be the cost of computing the approximate kernel between two embedded vectors (which is the cost of a scalar product in the embedded space). The cost of the exact search in the initial space has complexity O(C K L).

The exact search in the embedded space as described above has complexity O(M C K ) for step 1 (scalar products are negligible if E M ), O(N C K ) for steps 2 to 4 (steps 3 and 4 have constant complexity per data vector, which is negligible compared to C K for high-dimensional data), and O(N C K ) for step 5.

Hence this method is guaranteed to find the nearest neighbor of q with complexity

O ((M + N )C K + LC K ) . (27)
If C K C K (which is likely to be the case, especially for complicated kernels), and if M + N L, we can be sure to retrieve the nearest neighbor while performing much fewer calculations.

This exact search method was tested on 10 6 SIFT descriptors taken from the dataset BIGANN. Experiments show that it reduces the number of kernel values computed. Indeed, for M = 2, 048, 90% of the tested queries require less than 15,000 kernel computations, which is a comparison with less than 0.15% of the base with respect to the distance we are interested in. These comparisons are of negligible complexity, the exact search process in the embedded space thus roughly requires 10 6 scalar products in dimension 128 instead of 10 6 χ 2 kernel computations in dimension 128 for the exact search in the initial space, which leads to a speedup considering that scalar products have more optimized implementations than the χ 2 kernel.

On the other hand, this approach does not perform well on the Imagenet database. For this dataset, the Cauchy-Schwarz inequality is too pessimistic to provide a good selection of the vectors to be reranked.

Indeed, experiments showed that the number of reranked vectors reprensented 30% of the database. In this case, it is still possible to select fewer vectors by relaxing the Cauchy-Schwarz inequality and considering that αR(x)R(y) ≤ (x, y) ≤ βR(x)R(y),

where α and β are simply lower and upper bounds for cos(x, y). By empirically estimating values for α and β that work for many vectors, one can use concentration of measure inequalities to derive theoretical guarantees learned from data. However, one is not able then to precisely ensure the retrieval of the true nearest neighbor of a vector.

Figure 1 :

 1 Figure1: Proposed approximate search scheme. As opposed as the existing implicit hashing methods (top path), we first compute explicit vectors belonging to a Euclidean space, then apply an encoding method designed for Euclidean distances (bottom path).

Figure 3 :

 3 Figure 3: Performance as a function of the database size (1M to 200M vectors). Parameters for KPCA+PQ: D = 16, E = 64 and M = 1, 024.

Figure 4 :

 4 Figure 4: Comparison with the state-of-the-art: search quality for the χ 2 kernel with coded representations for 1M SIFT. Left: recall@R curves for a fixed size of B=256 bits. Right: recall@100 as a function of the number of bits (32-256). Parameters: KPCA+LSH → E = B and M =1,024; KPCA+PQ → E=128 and M =1,024.

Figure 5 :

 5 Figure 5: Comparison with the state-of-the-art: search quality for the χ 2 kernel with coded representations for 1.2M BOW. Left: recall@R curves for a fixed size of B=256 bits. Right: recall@1000 as a function of the number of bits (32-256). Parameters: KPCA+LSH → E = B and M = 1, 024; KPCA+PQ → E = 128 and M = 1, 024.

Figure 6 :

 6 Figure 6: Exact nearest neighbor search for a given query in a database of 10M 128-dimensional SIFT vectors (extracted from the BIGANN database), embedded in dimension 128 with KPCA, on χ 2 kernel. The reranked vectors are the neighbors which have an upper bound value higher than the lower bound of the approximate nearest neighbor.

Table 1 :

 1 Datasets used for the evaluation of nearest neighbor search 2. Full nearest neighbor search with the signatures:

	Dataset	Number of vectors Dim	Descriptor	URL
	SIFT1M	1M	128	HesAff + SIFT http://corpus-texmex.irisa.fr
	BIGANN 1M-1G	128	DOG + SIFT	http://corpus-texmex.irisa.fr
	Imagenet 1.261M	1,000 Bag-of-words	http://www.image-net.org

Acknoledgements

Florent Perronnin and Hervé Jégou have worked on this paper in the context of the ANR Fire-Id project. This work was supported in part by the European Research Council, PLEASE project (ERC-StG-2011-277906).

A Exact NN search with KPCA

In this appendix, we mention another benefit of using explicit embedding by KPCA for NN search with a Mercer kernel: it allows one to derive precision bounds on the approximation that can be used in a procedure ensuring exact recovery of the nearest neighbor.