Repository navigation
[MRG] Fix GMM rand map overflow - #872
Open
jonathan-legrand wants to merge 14 commits into
Open
jonathan-legrand wants to merge 14 commits into
jonathan-legrand wants to merge 14 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #872 +/- ##
=======================================
Coverage 97.00% 97.00%
=======================================
Files 128 128
Lines 26349 26390 +41
=======================================
+ Hits 25559 25599 +40
- Misses 790 791 +1 🚀 New features to boost your workflow:
|
eloitanguy
reviewed
Oct 5, 2026
…d/POT into gmm-map-overflow
Author
|
Thanks for your kind message! I renamed the The dictionary idea could avoid a few |
rflamary
reviewed
Oct 7, 2026
| return emd(w_s, w_t, D, log=log) | ||
|
|
||
|
|
||
| def logsumexp(a, scaling_factor, axis=None): |
Collaborator
There was a problem hiding this comment.
Hello instead of rewriting a logsumexp here it woudl be better to use the one form the backend nx.logsumext it probably does not have scaling_factor but that is an easy update (in backend.py" no?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of changes
I simplified the computation of the$T_{rand}$ map and used the
logsumexptrick to avoid overflows. I also added a test case that triggers overflow errors with the current main branch implementation and passes with the changes introduced in this request.Motivation and context / Related issue
I ran into overflow errors when transporting gaussian mixtures with the$T_{rand}$ map. They occur when a point of the source domain $x$ is far away from one of the target components.
The current implementation computes:
log_diff = log_g[:, None] - log_g[None, :]which is effectively:and then exponentiates this quantity :
weighted_exp = w_s[:, None] * nx.exp(log_diff)When the ratio$g_i(x)/g_j(x)$ is very large, the
expoverflows.I rewrote this computation using the$T_{rand}$ attribution probability, so I implemented one which is backend agnostic.
logsumexptrick. I saw that alogsumexpfunction is available throughnxbut it does not accept weights, which are required for computing theHow has this been tested (if it applies)
The
logsumexphas been tested for high (710) and low (0) logits and it behaves as expected. The tests pass for numpy and torch backends. I had to skip jax tests because the functions of thegmmmodule use a lot of array assignments.PR checklist