End-to-End Efficient Representation Learning via Cascading Combinatorial Optimization
Yeonwoo Jeong, Yoonsung Kim, Hyun Oh Song

TL;DR
This paper introduces a hierarchical quantization method for embedding representations that achieves state-of-the-art search accuracy and significantly faster inference speeds by optimizing sparse hash codes via flow networks.
Contribution
It proposes a novel hierarchical quantization approach combined with combinatorial optimization for efficient, accurate similarity search, enabling end-to-end training with polynomial-time algorithms.
Findings
State-of-the-art search accuracy on Cifar100 and ImageNet
Several orders of magnitude speedup in inference
Efficient end-to-end training via flow network optimization
Abstract
We develop hierarchically quantized efficient embedding representations for similarity-based search and show that this representation provides not only the state of the art performance on the search accuracy but also provides several orders of speed up during inference. The idea is to hierarchically quantize the representation so that the quantization granularity is greatly increased while maintaining the accuracy and keeping the computational complexity low. We also show that the problem of finding the optimal sparse compound hash code respecting the hierarchical structure can be optimized in polynomial time via minimum cost flow in an equivalent flow network. This allows us to train the method end-to-end in a mini-batch stochastic gradient descent setting. Our experiments on Cifar100 and ImageNet datasets show the state of the art search accuracy while providing several orders of…
| Triplet | Npairs | ||||||||||||||||
| test | train | test | train | ||||||||||||||
| Method | SUF | Pr@1 | Pr@4 | Pr@16 | SUF | Pr@1 | Pr@4 | Pr@16 | SUF | Pr@1 | Pr@4 | Pr@16 | SUF | Pr@1 | Pr@4 | Pr@16 | |
| Metric | 1.00 | 56.78 | 55.99 | 53.95 | 1.00 | 62.64 | 61.91 | 61.22 | 1.00 | 57.05 | 55.70 | 53.91 | 1.00 | 61.78 | 60.63 | 59.73 | |
| LSH | 138.83 | 52.52 | 48.67 | 39.71 | 135.64 | 60.45 | 58.10 | 54.00 | 29.74 | 53.55 | 50.75 | 43.03 | 30.75 | 59.87 | 58.34 | 55.35 | |
| DCH | 96.13 | 56.26 | 55.65 | 54.26 | 89.60 | 61.06 | 60.80 | 60.81 | 41.59 | 57.23 | 56.25 | 54.45 | 40.49 | 61.59 | 60.77 | 60.12 | |
| Th | 41.21 | 54.82 | 52.88 | 48.03 | 43.19 | 61.56 | 60.24 | 58.23 | 12.72 | 54.95 | 52.60 | 47.16 | 13.65 | 60.80 | 59.49 | 57.27 | |
| VQ | 22.78 | 56.74 | 55.94 | 53.77 | 40.35 | 62.54 | 61.78 | 60.98 | 34.86 | 56.76 | 55.35 | 53.75 | 31.35 | 61.22 | 60.24 | 59.34 | |
| [11] | 97.67 | 57.63 | 57.16 | 55.76 | 97.77 | 63.85 | 63.40 | 63.39 | 54.85 | 58.19 | 57.22 | 55.87 | 54.90 | 63.11 | 62.29 | 61.94 | |
| Ours | 97.67 | 58.42 | 57.88 | 56.58 | 97.28 | 64.73 | 64.63 | 64.69 | 101.1 | 58.28 | 57.79 | 56.92 | 97.47 | 63.06 | 62.62 | 62.44 | |
| Th | 14.82 | 56.55 | 55.62 | 52.90 | 15.34 | 62.41 | 61.68 | 60.89 | 5.09 | 56.52 | 55.28 | 53.04 | 5.36 | 61.65 | 60.50 | 59.50 | |
| VQ | 5.63 | 56.78 | 56.00 | 53.99 | 6.94 | 62.66 | 61.92 | 61.26 | 6.08 | 57.13 | 55.74 | 53.90 | 5.44 | 61.82 | 60.56 | 59.70 | |
| [11] | 76.12 | 57.30 | 56.70 | 55.19 | 78.28 | 63.60 | 63.19 | 63.09 | 16.20 | 57.27 | 55.98 | 54.42 | 16.51 | 61.98 | 60.93 | 60.15 | |
| Ours | 98.38 | 58.39 | 57.51 | 56.09 | 97.20 | 64.35 | 63.91 | 63.81 | 69.48 | 57.60 | 56.98 | 55.82 | 69.91 | 62.19 | 61.71 | 61.27 | |
| Th | 7.84 | 56.78 | 55.91 | 53.64 | 8.04 | 62.66 | 61.88 | 61.16 | 3.10 | 56.97 | 55.56 | 53.76 | 3.21 | 61.75 | 60.66 | 59.73 | |
| VQ | 2.83 | 56.78 | 55.99 | 53.95 | 2.96 | 62.62 | 61.92 | 61.22 | 2.66 | 57.01 | 55.69 | 53.90 | 2.36 | 61.78 | 60.62 | 59.73 | |
| [11] | 42.12 | 56.97 | 56.25 | 54.40 | 44.36 | 62.87 | 62.22 | 61.84 | 7.25 | 57.15 | 55.81 | 54.10 | 7.32 | 61.90 | 60.80 | 59.96 | |
| Ours | 94.55 | 58.19 | 57.42 | 56.02 | 93.69 | 63.60 | 63.35 | 63.32 | 57.09 | 57.56 | 56.70 | 55.41 | 58.62 | 62.30 | 61.44 | 60.91 | |
| Th | 4.90 | 56.84 | 56.01 | 53.86 | 5.00 | 62.66 | 61.94 | 61.24 | 2.25 | 57.02 | 55.64 | 53.88 | 2.30 | 61.78 | 60.66 | 59.75 | |
| VQ | 1.91 | 56.77 | 55.99 | 53.94 | 1.97 | 62.62 | 61.91 | 61.22 | 1.66 | 57.03 | 55.70 | 53.91 | 1.55 | 61.78 | 60.62 | 59.73 | |
| [11] | 16.19 | 57.11 | 56.21 | 54.20 | 16.52 | 62.81 | 62.14 | 61.58 | 4.51 | 57.15 | 55.77 | 54.01 | 4.52 | 61.81 | 60.69 | 59.77 | |
| Ours | 92.18 | 58.52 | 57.79 | 56.22 | 91.27 | 64.20 | 63.95 | 63.63 | 49.43 | 57.75 | 56.79 | 55.50 | 50.80 | 62.43 | 61.65 | 61.01 | |
| Triplet | Npairs | ||||||||
| Method | SUF | Pr@1 | Pr@4 | Pr@16 | SUF | Pr@1 | Pr@4 | Pr@16 | |
| Metric | 1.00 | 10.90 | 9.39 | 7.45 | 1.00 | 15.73 | 13.75 | 11.08 | |
| LSH | 164.25 | 8.86 | 7.23 | 5.04 | 112.31 | 11.71 | 8.98 | 5.56 | |
| DCH | 140.77 | 9.82 | 8.43 | 6.44 | 220.52 | 13.87 | 11.77 | 8.99 | |
| Th | 18.81 | 10.20 | 8.58 | 6.50 | 1.74 | 15.06 | 12.92 | 9.92 | |
| VQ | 146.26 | 10.37 | 8.84 | 6.90 | 451.42 | 15.20 | 13.27 | 10.96 | |
| [11] | 221.49 | 11.00 | 9.59 | 7.83 | 478.46 | 16.95 | 15.27 | 13.06 | |
| Ours | 590.41 | 10.91 | 9.58 | 7.85 | 952.49 | 17.00 | 15.53 | 13.54 | |
| Th | 6.33 | 10.82 | 9.30 | 7.32 | 1.18 | 15.70 | 13.69 | 10.96 | |
| VQ | 32.83 | 10.88 | 9.33 | 7.39 | 116.26 | 15.62 | 13.68 | 11.15 | |
| [11] | 60.25 | 11.10 | 9.64 | 7.73 | 116.61 | 16.40 | 14.49 | 12.00 | |
| Ours | 533.86 | 11.14 | 9.72 | 7.96 | 1174.35 | 17.22 | 15.57 | 13.63 | |
| Th | 3.64 | 10.87 | 9.38 | 7.42 | 1.07 | 15.73 | 13.74 | 11.07 | |
| VQ | 13.85 | 10.90 | 9.38 | 7.44 | 55.80 | 15.74 | 13.74 | 11.12 | |
| [11] | 27.16 | 11.20 | 9.55 | 7.60 | 53.98 | 16.24 | 14.32 | 11.73 | |
| Ours | 477.86 | 11.21 | 9.72 | 7.94 | 1297.98 | 17.09 | 15.37 | 13.39 | |
| Triplet | Npairs | |||||
| Cifar-100 | ImageNet | Cifar-100 | ImageNet | |||
| train | test | val | train | test | val | |
| LSH | 62.94 | 53.11 | 37.90 | 43.80 | 37.45 | 36.00 |
| DCH | 86.11 | 68.88 | 45.55 | 80.74 | 65.62 | 50.01 |
| Th | 68.20 | 54.95 | 31.62 | 51.46 | 44.32 | 15.20 |
| VQ | 76.85 | 62.68 | 45.47 | 80.25 | 66.69 | 53.74 |
| [11] | 89.11 | 68.95 | 48.52 | 84.90 | 68.56 | 55.09 |
| Ours | 89.95 | 69.64 | 61.21 | 86.80 | 71.30 | 65.49 |
| Method | SUF | Pr@1 | Pr@4 | Pr@16 | |
|---|---|---|---|---|---|
| Metric | 1.00 | 21.55 | 19.11 | 16.06 | |
| LSH | 33.75 | 18.49 | 15.50 | 11.14 | |
| Th | 10.98 | 20.25 | 17.22 | 13.66 | |
| VQ-train | 54.30 | 20.15 | 18.10 | 14.85 | |
| VQ-test | 57.44 | 20.59 | 18.31 | 15.32 | |
| [11] | 56.35 | 21.35 | 18.49 | 15.32 | |
| Ours | 78.23 | 21.46 | 18.88 | 15.67 | |
| Th | 4.55 | 21.27 | 18.86 | 15.68 | |
| VQ-train | 15.29 | 21.51 | 19.03 | 15.88 | |
| VQ-test | 16.43 | 21.58 | 18.93 | 15.94 | |
| [11] | 15.99 | 22.12 | 19.21 | 15.95 | |
| Ours | 71.14 | 22.12 | 18.63 | 15.34 | |
| Th | 2.79 | 21.53 | 19.11 | 15.99 | |
| VQ-train | 7.80 | 21.56 | 19.11 | 16.03 | |
| VQ-test | 8.20 | 21.58 | 19.09 | 16.06 | |
| [11] | 7.24 | 22.18 | 19.40 | 16.10 | |
| Ours | 84.04 | 21.97 | 18.87 | 15.56 |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Image and Video Retrieval Techniques · Domain Adaptation and Few-Shot Learning · Advanced Neural Network Applications
MethodsSPEED: Separable Pyramidal Pooling EncodEr-Decoder for Real-Time Monocular Depth Estimation on Low-Resource Settings
End-to-End Efficient Representation Learning
via Cascading Combinatorial Optimization
Yeonwoo Jeong, Yoonsung Kim, Hyun Oh Song
Department of Computer Science and Engineering, Seoul National University, Seoul, Korea
{yeonwoo, yskim227, hyunoh}@mllab.snu.ac.kr
Abstract
We develop hierarchically quantized efficient embedding representations for similarity-based search and show that this representation provides not only the state of the art performance on the search accuracy but also provides several orders of speed up during inference. The idea is to hierarchically quantize the representation so that the quantization granularity is greatly increased while maintaining the accuracy and keeping the computational complexity low. We also show that the problem of finding the optimal sparse compound hash code respecting the hierarchical structure can be optimized in polynomial time via minimum cost flow in an equivalent flow network. This allows us to train the method end-to-end in a mini-batch stochastic gradient descent setting. Our experiments on Cifar100 and ImageNet datasets show the state of the art search accuracy while providing several orders of magnitude search speedup respectively over exhaustive linear search over the dataset.
1 Introduction
Learning the feature embedding representation that preserves the notion of similarities among the data is of great practical importance in machine learning and vision and is at the basis of modern similarity-based search [22, 24], verification [27], clustering [2], retrieval [26, 25], zero-shot learning [32, 5], and other related tasks. In this regard, deep metric learning methods [2, 22, 24] have shown advances in various embedding tasks by training deep convolutional neural networks end-to-end encouraging similar pairs of data to be close to each other and dissimilar pairs to be farther apart in the embedding space.
Despite the progress in improving the embedding representation accuracy, improving the inference efficiency and scalability of the representation in an end-to-end optimization framework is relatively less studied. Practitioners deploying the method on large-scale applications often resort to employing post-processing techniques such as embedding thresholding [1, 33] and vector quantization [28] at the cost of the loss in the representation accuracy. Recently, Jeong & Song [11] proposed an end-to-end learning algorithm for quantizable representations which jointly optimizes the quality of the convolutional neural network based embedding representation and the performance of the corresponding sparsity constrained compound binary hash code and showed significant retrieval speedup on ImageNet [21] without compromising the accuracy.
In this work, we seek to learn hierarchically quantizable representations and propose a novel end-to-end learning method significantly increasing the quantization granularity while keeping the time and space complexity manageable so the method can still be efficiently trained in a mini-batch stochastic gradient descent setting. Besides the efficiency issues, however, naively increasing the quantization granularity could cause a severe degradation in the search accuracy or lead to dead buckets hindering the search speedup.
To this end, our method jointly optimizes both the sparse compound hash code and the corresponding embedding representation respecting a hierarchical structure. We alternate between performing cascading optimization of the optimal sparse compound hash code per each level in the hierarchy and updating the neural network to adjust the corresponding embedding representations at the active bits of the compound hash code.
Our proposed learning method outperforms both the reported results in [11] and the state of the art deep metric learning methods [22, 24] in retrieval and clustering tasks on Cifar-100 [13] and ImageNet [21] datasets while, to the best of our knowledge, providing the highest reported inference speedup on each dataset over exhaustive linear search.
2 Related works
Embedding representation learning with neural networks has its roots in Siamese networks [4, 9] where it was trained end-to-end to pull similar examples close to each other and push dissimilar examples at least some margin away from each other in the embedding space. [4] demonstrated the idea could be used for signature verification tasks. The line of work since then has been explored in wide variety of practical applications such as face recognition [27], domain adaptation [23], zero-shot learning [32, 5], video representation learning [29], and similarity-based interior design [2], etc.
Another line of research focuses on learning binary hamming ranking [30, 34, 19, 14] representations via neural networks. Although comparing binary hamming codes is more efficient than comparing continuous embedding representations, this still requires the linear search over the entire dataset which is not likely to be as efficient for large scale problems. [7, 16] seek to vector quantize the dataset and back propagate the metric loss, however, it requires repeatedly running k-means clustering on the entire dataset during training with prohibitive computational complexity.
We seek to jointly learn the hierarchically quantizable embedding representation and the corresponding sparsity constrained binary hash code in an efficient mini-batch based end-to-end learning framework. Jeong & Song [11] motivated maintaining the hard constraint on the sparsity of hash code to provide guaranteed retrieval inference speedup by only considering out of buckets and thus avoiding linear search over the dataset. We also explicitly maintain this constraint, but at the same time, greatly increasing the number of representable buckets by imposing an efficient hierarchical structure on the hash code to unlock significant improvement in the speedup factor.
3 Problem formulation
Consider the following hash function
[TABLE]
under the constraint that . The idea is to optimize the weights in the neural network , take highest activation dimensions, activate the corresponding dimensions in the binary compound hash code , and hash the data into the corresponding active buckets of a hash table . During inference, a query is given, and all the hashed items in the active bits set by the hash function are retrieved as the candidate nearest items. Often times [28], these candidates are reranked based on the euclidean distance in the base embedding representation space.
Given a query , the expected number of retrieved items is . Then, the expected speedup factor [11] (SUF) is the ratio between the total number of items and the expected number of retrieved items. Concretely, it becomes . In case , this ratio approaches .
Now, suppose we design a hash function so that the function has total (i.e. exponential in some integer parameter ) indexable buckets. The expected speedup factor [11] approaches which means the query time speedup increases linearly with the number of buckets. However, naively increasing the bucket size for higher speedup has several major downsides. First, the hashing network has to output and hold activations in the memory at the final layer which can be unpractical in terms of the space efficiency for large scale applications. Also, this could also lead to dead buckets which are under-utilized and degrade the search speedup. On the other hand, hashing the items uniformly at random among the buckets could help to alleviate the dead buckets but this could lead to a severe drop in the search accuracy.
Our approach to this problem of maintaining a large number of representable buckets while preserving the accuracy and keeping the computational complexity manageable is to enforce a hierarchy among the optimal hash codes in an efficient tree structure. First, we use number of activations instead of activations in the last layer of the hash network. Then, we define the unique mapping between the activations to buckets by the following procedure.
Denote the hash code as where and . The superscript denotes the level index in the hierarchy. Now, suppose we construct a tree with branching factor , depth where the root node has the level index of [math]. Let each leaf node in represent a bucket indexed by the hash function . Then, we can interpret each vector to indicate the branching from depth to depth in . Note, from the construction of , the branching is unique until level , but the last branching to the leaf nodes is multi-way because bits are set due to the sparsity constraint at level . Figure 1 illustrates an example translation from the given hash activation to the tree bucket index for and . Concretely, the hash function can be expressed compactly as Equation 1.
[TABLE]
where denotes the tensor multiplication operator between two vectors. The following section discusses how to find the optimal hash code and the corresponding activation respecting the hierarchical structure of the code.
4 Methods
To compute the optimal set of embedding representations and the corresponding hash code, the embedding representations are first required in order to infer which activations to set in the hash code, but to learn the embedding representations, it requires the hash code to determine which dimensions of the activations to adjust so that similar items would get hashed to the same buckets and vice versa. We take the alternating minimization approach iterating over computing the sparse hash codes respecting the hierarchical quantization structure and updating the network parameters indexed at the given hash codes per each mini-batch. Section 4.1 and Section 4.3 formalize the subproblems in detail.
4.1 Learning the hierarchical hash code
Given a set of continuous embedding representation , we wish to compute the optimal binary hash code so as to hash similar items to the same buckets and dissimilar items to different buckets. Furthermore, we seek to constrain the hash code to simultaneously maintain the hierarchical structure and the hard sparsity conditions throughout the optimization process. Suppose items and are dissimilar items, in order to hash the two items to different buckets, at each level of , we seek to encourage the hash code for each item at level , and to differ. To achieve this, we optimize the hash code for all items per each level sequentially in cascading fashion starting from the first level to the leaf nodes as shown in Equation 2.
[TABLE]
where denotes the set of dissimilar pairs of data and denotes the indicator function. Concretely, given the hash codes from all the previous levels, we seek to minimize the following discrete optimization problem in Equation 3, subject to the same constraints as in Equation 2, sequentially for all levels111In Equation 3, we omit the dependence of for all to avoid the notation clutter. . The unary term in the objective encourages selecting as large elements of each embedding vector as possible while the second term loops over all pairs of dissimilar siblings and penalizes for their orthogonality. The last term encourages selecting as orthogonal elements as possible for a pair of hash codes from different classes in the current level . The last term also makes sure, in the event that the second term becomes zero, the hash code still respects orthogonality among dissimilar items. This can occur when the hash code for all the previous levels was computed perfectly splitting dissimilar pairs into different branches and the second term becomes zero.
[TABLE]
where denotes the set of pairs of siblings at level in , and encodes the pairwise cost for the sibling and the orthogonality terms respectively. However, optimizing Equation 3 is NP-hard in general even in the simpler case of [3, 11]. Inspired by [11], we use the average embedding of each class within the minibatch as shown in Equation 4.
[TABLE]
where , is the number of unique classes in the minibatch, and we assume each class has examples in the minibatch (i.e. npairs [24] minibatch construction). Note, in accordance with the deep metric learning problem setting [22, 24, 11], we assume we are given access to the label adjacency information only within the minibatch.
The objective in Equation 4 upperbounds the objective in Equation 3 (denote as ) by a gap which depends only on . Concretely, rewriting the summation in the unary term in , we get
[TABLE]
Minimizing the upperbound in Equation 5 over is identical to minimizing the objective in Equation 4 since each example in class shares the same class mean embedding vector . Absorbing the factor into the cost matrices i.e. and , we arrive at the upperbound minimization problem defined in Equation 4. In the upperbound problem Equation 4, we consider the case where the pairwise cost matrices are diagonal matrices of non-negative values. 1 in the following subsection proves that finding the optimal solution of the upperbound problem in Equation 4 is equivalent to finding the minimum cost flow solution of the flow network illustrated in Figure 2. Section B in the supplementary material shows the running time to compute the minimum cost flow (MCF) solution is approximately linear in and . On average, it takes 24 ms and 53 ms to compute the MCF solution (discrete update) and to take a gradient descent step with npairs embedding [24] (network update), respectively on a machine with 1 TITAN-XP GPU and Xeon E5-2650.
4.2 Equivalence of the optimization problem to minimum cost flow
Theorem 1**.**
The optimization problem in Equation 4 can be solved exactly in polynomial time by finding the minimum cost flow solution on the flow network G’.
Proof.
Suppose we construct a vertex set and partition into with the partition of from equivalence relation 222Define . Here, we will define as a union of subsets of size (i.e. each element in is a singleton without a sibling), and as the rest of the subsets (of size greater than or equal to). Concretely, and .
Then, we construct set of complete bipartite graphs where we define and . Now suppose we construct a directed graph by directing all edges from to , attaching source to all vertices in , and attaching sink to all vertices in . Formally, . The edges in inherit all directed edges from source to vertices in , edges from vertices in to sink, and . We also attach number of edges for each vertex to and attach number of edges from each vertex to . Concretely, is
[TABLE]
Edges incident to have capacity and cost for all . The edges between and have capacity and cost . Each edge between and has capacity and cost . Each edge between and has capacity and cost . Figure 2 illustrates the flow network . The amount of flow from source to sink is . The figure omits the vertices in and the corresponding edges to to avoid the clutter.
Now we define the flow for each edge indexed both by flow configuration where and below in Equation 8.
[TABLE]
To prove the equivalence of computing the minimum cost flow solution and finding the minimum binary assignment in Equation 4, we need to show (1) that the flow defined in Equation 8 is feasible in and (2) that the minimum cost flow solution of the network and translating the computed flows to in Equation 4 indeed minimizes the discrete optimization problem. We first proceed with the flow feasibility proof.
It is easy to see the capacity constraints are satisfied by construction in Equation 8 so we prove that the flow conservation conditions are met at each vertices. First, the output flow from the source is equal to the input flow. For each vertex , the amount of input flow is and the output flow is the same .
For , for each vertex , denote the input flow as . The output flow is . The second term vanishes because of Equation 8 (iii).
The last flow conservation condition is to check the connections from each vertex to the sink. Denote the input flow at the vertex as . The output flow is which is identical to the input flow. Therefore, the flow construction in Equation 8 is feasible in .
The second part of the proof is to check the optimality conditions and show the minimum cost flow finds the minimizer of Equation 4. Denote, as the minimum cost flow solution of the network which minimizes the total cost . Also denote the optimal flow from to as . By optimality of the flow, , . By Lemma 3, the lhs of the inequality is equal to . Additionally, Lemma 4 shows the rhs of the inequality is equal to . Finally,
[TABLE]
This shows computing the minimum cost flow solution on and converting the flows to ’s, we can find the minimizer of the objective in Equation 4. ∎
Lemma 1**.**
Given the minimum cost flow of the network , the total cost of the flow is .
Proof.
Proof in section A.2 of the supplementary material. ∎
Lemma 2**.**
Given a feasible flow of the network , the total cost of the flow is .
Proof.
Proof in section A.2 of the supplementary material. ∎
4.3 Learning the embedding representation given the hierarchical hash codes
Given a set of binary hash codes for the mean embeddings computed from Equation 4, we can derive the hash codes for all examples in the minibatch, and update the network weights given the hierarchical hash codes in turn. The task is to update the embedding representations, , so that similar pairs of data have similar embedding representations indexed at the activated hash code dimensions and vice versa. Note, In terms of the hash code optimization in Equation 4 and the bound in Equation 5, this embedding update has the effect of tightening the bound gap .
We employ the state of the art deep metric learning algorithms (denote as ) such as triplet loss with semi-hard negative mining [22] and npairs loss [24] for this subproblem where the distance between two examples and at hierarchy level is defined as . Utilizing the logical OR of the two binary masks, in contrast to independently indexing the representation with respective masks, to index the embedding representations helps prevent the pairwise distances frequently becoming zero due to the sparsity of the code. Note, this formulation in turn accommodates the backpropagation gradients to flow more easily. In our embedding representation learning subproblem, we need to learn the representations which respect the tree structural constraint on the corresponding hash code where and . To this end, we decompose the problem and compute the embedding loss per each hierarchy level separately.
Furthermore, naively using the similarity labels to define similar pairs versus dissimilar pairs during the embedding learning subproblem could create a discrepancy between the hash code discrete optimization subproblem and the embedding learning subproblem leading to contradicting updates. Suppose two examples and are dissimilar and both had the highest activation at the same dimension and the hash code for some level was identical i.e. . Enforcing the metric learning loss with the class labels, in this case, would lead to increasing the highest activation for one example and decreasing the highest activation for the other example. This can be problematic for the example with decreased activation because it might get hashed to another occupied bucket after the gradient update and this can repeat causing instability in the optimization process.
However, if we relabel the two examples so that they are treated as the same class as long as they have the same hash code at the level, the update wouldn’t decrease the activations for any example, and the sibling term (the second term) in Equation 4 would automatically take care of splitting the two examples in the next subsequent levels.
To this extent, we apply label remapping as follows. , where assigns arbitrary unique labels to each unique configuration of . Concretely, . Finally, the embedding representation learning subproblem aims to solve Equation 7 given the hash codes and the remapped labels. Section C in the supplementary material includes the ablation study of label remapping.
[TABLE]
Following the protocol in [11], we use the Tensorflow implementation of deep metric learning algorithms in tf.contrib.losses.metric_learning.
5 Implementation details
Network architecture For fair comparison, we follow the protocol in [11] and use the NIN [15] architecture (denote the parameters ) with leaky relu [31] with as activation function and train Triplet embedding network with semi-hard negative mining [22], Npairs network [24] from scratch as the base model, and snapshot the network weights () of the learned base model. Then we replace the last layer in () with a randomly initialized dimensional fully connected projection layer () and finetune the hash network (denote the parameters as ). Algorithm 1 summarizes the learning procedure.
Hash table construction and query We use the learned hash network and apply Equation 1 to convert into the hash code and use the base embedding network to convert the data into the embedding representation . Then, the embedding representation is hashed to buckets corresponding to the set bits in the hash code. During inference, we convert a query data into the hash code and into the embedding representation . Once we retrieve the union of all bucket items indexed at the set bits in the hash code, we apply a reranking procedure [28] based on the euclidean distance in the embedding space.
Evaluation metrics Following the evaluation protocol in [11], we report our accuracy results using precision@k (Pr@k) and normalized mutual information (NMI) [17] metrics. Precision@k is computed based on the reranked ordering (described above) of the retrieved items from the hash table. We evaluate NMI, when the code sparsity is set to , treating each bucket as an individual cluster. We report the speedup results by comparing the number of retrieved items versus the total number of data (exhaustive linear search) and denote this metric as SUF.
6 Experiments
We report our results on Cifar-100 [13] and ImageNet [21] datasets and compare against several baseline methods. First baseline methods are the state of the art deep metric learning models [22, 24] performing an exhaustive linear search over the whole dataset given a query data (denote as ‘Metric’). Next baseline is the Binarization transform [1, 33] where the dimensions of the hash code corresponding to the top dimensions of the embedding representation are set (denote as ‘Th’). Then we perform vector quantization [28] on the learned embedding representation from the deep metric learning methods above on the entire dataset and compute the hash code based on the indices of the nearest centroids (denote as ‘VQ’). Another baseline is the quantizable representation in [11](denote as [11]). In both Cfar-100 and ImageNet, we follow the data augmentation and preprocessing steps in [11] and train the metric learning base model with the same settings in [11] for fair comparison. In Cifar-100 experiment, we set and for the npairs network and the triplet network, respectively. In ImageNet experiment, we set and for the npairs network and the triplet network, respectively. In ImageNetSplit experiment, we set . We also perform LSH hashing [10] baseline and Deep Cauchy Hashing [6] baseline which both generate -bit binary hash codes with buckets and compare against other methods when (denote as ‘LSH’ and ‘DCH’, respectively). For the fair comparison, we set the number of buckets, .
6.1 Cifar-100
Cifar-100 [13] dataset has classes. Each class has images for train and images for test. Given a query image from test, we experiment the search performance both when the hash table is constructed from train and from test. The batch size is set to in Cifar-100 experiment. We finetune the base model for k iterations and decayed the learning rate to of previous learning rate after k iterations when we optimize our methods. Table 1 shows the results from the triplet network and the npairs network respectively. The results show that our method not only outperforms search accuracies of the state of the art deep metric learning base models but also provides the superior speedup over other baselines.
6.2 ImageNet
ImageNet ILSVRC-2012 [21] dataset has classes and comes with train ( images) and val set ( images). We use the first nine splits of train set to train our model, the last split of train set for validation, and use validation dataset to test the query performance. We use the images downsampled to from [8]. We finetune npairs base model and triplet base model as in [11] and add a randomly initialized fully connected layer to learn hierarchical representation. Then, we train the parameters in the newly added layer with other parameters fixed. When we train with npairs loss, we set the batch size to and train for k iterations decaying the learning rate to of previous learning rate after each k iterations. Also, when we train with triplet loss, we set the batch size to and train for k iterations decaying the learning rate of of previous learning rate after each k iterations. Our results in Table 2 show that our method outperforms the state of the art deep metric learning base models in search accuracy while providing up to speedup over exhaustive linear search. Table 3 compares the NMI metric and shows that the hash table constructed from our representation yields buckets with significantly better class purity on both datasets and on both the base metric learning methods.
6.3 ImageNetSplit
In order to test the generalization performance of our learned representation against previously unseen classes, we performed an experiment on ImageNet where the set of classes for training and testing are completely disjoint. Each class in ImageNet ILSVRC-2012 [21] dataset has super-class based on WordNet [18]. We select super-classes which have exactly two sub-classes in classes of ImageNet ILSVRC-2012 dataset. Then, we split the two sub-classes of each super-class into and , where . Section D in the supplementary material shows the class names in and . We use the images downsampled to from [8]. We train the models with triplet embedding on and test the models on . The batch size is set to in ImageNetSplit dataset. We finetune the base model for k iterations and decayed the learning rate to of previous learning rate after k iterations when we optimize our methods. We also perform vector quantization with the centroids obtained from (denote as ‘VQ-train’) and (denote as ‘VQ-test’), respectively. Table 4 shows our method preserves the accuracy without compromising the speedup factor.
Note, in all our experiments in Tables 1, 2, 3 and 4, while all the baseline methods show severe degradation in the speedup over the code compound parameter , the results show that the proposed method robustly withstands the speedup degradation over . This is because our method 1) greatly increases the quantization granularity beyond other baseline methods and 2) hashes the items more uniformly over the buckets. In effect, indexing multiple buckets in our quantized representation does not as adversarially effect the search speedup as other baselines. Figure 3 shows a qualitative result with npairs network on Cifar-100, where . As an interesting side effect, our qualitative result indicates that even though our method does not use any super/sub-class labels or the entire label information during training, optimizing for the objective in Equation 2 naturally discovers and organizes the data exhibiting a meaningful hierarchy where similar subclasses share common parent nodes.
7 Conclusion
We have shown a novel end-to-end learning algorithm where the quantization granularity is significantly increased via hierarchically quantized representations while preserving the search accuracy and maintaining the computational complexity practical for the mini-batch stochastic gradient descent setting. This not only provides the state of the art accuracy results but also unlocks significant improvement in inference speedup providing the highest reported inference speedup on Cifar100 and ImageNet datasets respectively.
Acknowledgements
This work was partially supported by Kakao, Kakao Brain and Basic Science Research Program through the National Research Foundation of Korea (NRF) (2017R1E1A1A01077431). Hyun Oh Song is the corresponding author.
Supplementary material
A. Proofs for equivalence
A.1 Recap for flow definition
[TABLE]
A.2 Proofs for lemma1 and lemma2
Lemma 3**.**
Given the minimum cost flow of the network , the total cost of the flow is .
Proof.
The total minimum cost flow is
[TABLE]
Also, for , denote the amount of input flow at each vertex given the minimum cost flow as . Also, denote the amount of input flow at each vertex as . Then, from the optimality of the minimum cost flow, and . Therefore, the total cost for optimal flow is
[TABLE]
∎
Lemma 4**.**
Given a feasible flow of the network , the total cost of the flow is .
Proof.
The total cost proof is similar to Lemma 3 except that we use the flow conditions from Equation 8 (iii) and Equation 8 (iv) instead of the optimality of the flow.
[TABLE]
∎
B. Time complexity
C. Effect of label remapping
We performed the ablation study without the label remapping method. ‘Ours-r’ in Table 6 and Table 7 shows the results without the remapping. The ablation study shows that the proposed hierarchical structure leads to much larger improvements than the remapping method.
D. ImagenetSplit Detail
Table 5 shows the and explicitly.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] P. Agrawal, R. Girshick, and J. Malik. Analyzing the performance of multilayer neural networks for object recognition. In ECCV , 2014.
- 2[2] S. Bell and K. Bala. Learning visual similarity for product design with convolutional neural networks. In SIGGRAPH , 2015.
- 3[3] Y. Boykov, O. Veksler, and R. Zabih. Fast approximate energy minimization via graph cuts. IEEE Transactions on pattern analysis and machine intelligence , 2001.
- 4[4] J. Bromley, I. Guyon, Y. Lecun, E. Sackinger, and R. Shah. Signature verification using a "siamese" time delay neural network. In NIPS , 1994.
- 5[5] M. Bucher, S. Herbin, and F. Jurie. Improving semantic embedding consistency by metric learning for zero-shot classiffication. In ECCV , 2016.
- 6[6] Y. Cao, M. Long, B. Liu, and J. Wang. Deep cauchy hashing for hamming space retrieval. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) , June 2018.
- 7[7] Y. Cao, M. Long, J. Wang, H. Zhu, and Q. Wen. Deep quantization network for efficient image retrieval. In AAAI , 2016.
- 8[8] P. Chrabaszcz, I. Loshchilov, and F. Hutter. A downsampled variant of imagenet as an alternative to the cifar datasets. ar Xiv preprint ar Xiv:1707.08819 , 2017.
