Bayesian Metric Learning for Uncertainty Quantification in Image Retrieval

We propose the first Bayesian encoder for metric learning. Rather than relying on neural amortization as done in prior works, we learn a distribution over the network weights with the Laplace Approximation. We actualize this by first proving that the contrastive loss is a valid log-posterior. We then propose three methods that ensure a positive definite Hessian. Lastly, we present a novel decomposition of the Generalized Gauss-Newton approximation. Empirically, we show that our Laplacian Metric Learner (LAM) estimates well-calibrated uncertainties, reliably detects out-of-distribution examples, and yields state-of-the-art predictive performance.

Paper

References (53)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer Stu96/10 · confidence 4/52023-07-04

Summary

This paper presents a Laplace approximation-based probabilistic retrieval approach (aka. Bayesian metric learning for image retrieval). The author provides a probabilistic view of the contrastive loss based on the von-Mises Fisher distribution and corrections for the Hessian positive definiteness. Extensive experimental evaluations are performed, demonstrating the advantages of the presented approach in calibrated uncertainties, out-of-distribution detection, close-set and open-set retrieval, and ablations on a few parameters of design choices.

Strengths

[Originality] This paper presents the use of Laplace approximation instead of amortized inference for probabilistic retrieval. Although similar ideas have been proposed to improve the amortization gap of variational autoencoders in several prior works, its development in the context of metric learning is novel. This includes the introduction of a probabilistic view of the contrastive loss and the utilization of the Hessian approximation based on GCN. On the other hand, previous Bayesian metric learning approaches have also been proposed, such as hedge instance embedding (HIE) and probabilistic face embeddings (PFE). In this regard, the novelty of this work lies in the contrastive learning-based loss and the learning of stochastic embeddings based on the Laplacian autoencoder (Miani, M. et al., 2022). Miani, M., Warburg, F., Moreno-Muñoz, P., Skafte, N., & Hauberg, S. (2022). Laplacian autoencoders for learning stochastic representations. *Advances in Neural Information Processing Systems*, *35*, 21059-21072. [Quality] Extensive empirical evaluations, including a careful ablation study, are conducted. The results demonstrate that the proposed approach outperforms HIE and PFE in the considered cases. [Clarity] The paper effectively uses figures to demonstrate ideas. However, I do find the need of reading with jumps between the main text and the supplemental material in order to grasp the concept. The organization can be improved. [Significance] This paper demonstrates uncertainty quantification based on Laplace approximation in the context of probabilistic retrieval. This is an important topic for improving the robustness and mitigating the silent failure of deep neural network systems. The main contribution of this paper appears to be the empirical study, which can be informative and useful for practitioners.

Weaknesses

It appears that this paper builds upon prior work, including the Laplacian autoencoder (Miani, M. et al., 2022), as well as several works on uncertainty in metric learning. Consequently, I am more concerned about the unique technical contributions of this work. In this regard, the necessity of the probabilistic view of the contrastive loss is not well presented and not well motivated. Another missing piece is how to perform test-time retrieval within the proposed framework and how its efficiency compares to the amortized approach. Given a query image, does the proposed approach learn a stochastic representation for it? Is the retrieval based on ranking the deterministic similarities between the query image and all other candidate images? If not, how is it performed? The organization and clarity of this paper could be improved. If certain results are deemed important enough, they should be moved into the main text. The authors should focus on introducing the unique aspects of this work and provide a strong motivation for them, such as the Von Mises-Fisher distribution. The frequent references to the Appendix disrupt the logical flow of the paper.

Questions

The probabilistic view in the supplemental also seems a little bit weird to me since both argument and parameter are data-dependent. Would it be sufficient to just treat the probabilistic contrastive likelihood as a second-order differentiable loss, if they are mathematically equivalent anyway? What are the main roadblocks that have been overcome in applying the Laplacian autoencoder (LAE) to probabilistic retrieval? Are there any other ways of approximating Hessian for contrastive loss, while still maintains scalability and positive definiteness? Is KFAC applicable, e.g., Ritter et al., 2018? Ritter, H., Botev, A., & Barber, D. (2018, January). A scalable laplace approximation for neural networks. In 6th International Conference on Learning Representations, ICLR 2018-Conference Track Proceedings (Vol. 6). International Conference on Representation Learning.

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

3 good

Presentation

2 fair

Contribution

3 good

Limitations

The authors discussed limitations about computation load which I think is reasonable.

Reviewer Z8Se7/10 · confidence 5/52023-07-05

Summary

The authors show that contrastive loss can be viewed as a likelihood after projection onto the spherical space. This consequently allows them to use the Laplace approximation to estimate the posterior over the parameters. To make the construction further amenable to estimation, the authors propose approaches to make the Hessian positive definite. Finally, the experimental results and ablations go into details about the design choices.

Strengths

- The authors use a conceptually simple approach to constructing approximate posteriors on top of neural networks using the Laplace approximation. - The authors provide several analogies for various concepts introduced which makes the reader comfortable, and would be resourceful paper for the community. - Most design choices in the method are covered by ablations, which is much appreciated.

Weaknesses

- The Laplace approximation hinges on an assumption of vanishing gradient which may not be true for modern large neural networks and large datasets used for representation learning. See Question 2. - The overall method involves a fair number of moving parts, and it would be good to reconcile them as a single algorithm or a list of bullet points for easy digestion for the reader. - The method can be computationally expensive, and the authors have to resort to construct stochasticity of the last-layer parameters only. Much of the post-hoc LA literature seems to be working with a similar setup, so I do not count this as a major weakness of this paper but rather the whole community. ### Minor - Please use `\citet` instead of `\citep` for references directly referring to the paper, for instance in Line 164. - It would be great to have Figure 3 on the same page as the text on ensuring positive definiteness on Page 4.

Questions

1. In Line 46, the authors claim that they do not assume any distribution on the stochastic embeddings. But the choice of using Laplacian approximation on the parameters to construct the posterior implicitly makes an assumption on the constructed embeddings. Could the authors clarify this? 2. As stated in Eq. (2), the Laplace approximation comes from a second-order Taylor expansion, where the first-order gradient vanishes due to $\theta^\star$ being the optima. Does this does really happen in practice, and how numerically close are we to zero for instance w.r.t. the size of models/data? 3. Could the authors confirm if my understanding of the overall approach is correct? (a) Using online LA to construct the posterior (b) Use samples from the posterior to construct stochastic embeddings (c) Use embedding samples to construct $\kappa$ for the von Mises-Fisher distribution which is used as a single number to quantify uncertainty.

Rating

7: Accept: Technically solid paper, with high impact on at least one sub-area, or moderate-to-high impact on more than one areas, with good-to-excellent evaluation, resources, reproducibility, and no unaddressed ethical considerations.

Confidence

5: You are absolutely certain about your assessment. You are very familiar with the related work and checked the math/other details carefully.

Soundness

4 excellent

Presentation

3 good

Contribution

4 excellent

Limitations

Yes. See also weaknesses and questions.

Reviewer SAQp5/10 · confidence 4/52023-07-10

Summary

They propose a Bayesian encoder for metric learning. They learn a distribution over the network weights with the Laplace approximation. They first prove that the contrastive loss is a negative log-likelihood on the spherical space. They propose three methods that ensure a positive definitive covariance matrix. They present a novel decomposition of the Generalized Gauss-Newton approximation. The empirical results leads previous methods on OOD examples.

Strengths

- Well organized paper and good writing. Clearly presenting the idea. Code released. - The bayesian approach for uncertainty measurement in metric learning is interesting. - The method show improved results, especially on OOD examples, and ablation study is comprehensive.

Weaknesses

- First the experimental results only achieved limited improvement. - As the paper claimed, The method is slow in computation as it is a bayesian method. - The paper only focus on a classical contrastive loss which is a margin-based loss, how about other cases? for example, the proxy-based losses? - Overall the performance improvement is not significant, and the computational efficiency is not competitive, compared with other uncertainty method.

Questions

1. Could you provide a systematic analysis of the computational efficiency? 2. Proxy-anchor loss can be a good case to study with this uncertainty measurement.

Rating

5: Borderline accept: Technically solid paper where reasons to accept outweigh reasons to reject, e.g., limited evaluation. Please use sparingly.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

3 good

Presentation

4 excellent

Contribution

3 good

Limitations

yes, they have addressed the limitations of the paper.

Reviewer Z8Se2023-08-14

Thank you for the clarifications. I maintain my accept score.

Reviewer SAQp2023-08-19

Thanks for providing the rebuttal, which addresses some of the previous concerns. After reading the other reviewers' comments, I slightly improved my rating to Borderline Accept.

Reviewer Stu92023-08-19

Thank you for providing the rebuttal! I've read it and I maintain my current rating. If "(1) proving that the contrastive loss is a log-likelihood" is viewed as the key technical contribution by the authors, it deserves more presence in the main text - It was put in Appendix D only.

Authorsrebuttal2023-08-20

Thanks

Thanks for the support and feedback. To bring more attention to the likelihood-contribution of the paper, we propose to include a proof sketch showing that the contrastive loss is indeed a log-likelihood.

Program Chairsdecision2023-09-21

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC