Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #870 +/- ##
==========================================
+ Coverage 96.86% 96.88% +0.02%
==========================================
Files 128 128
Lines 26304 26319 +15
==========================================
+ Hits 25480 25500 +20
+ Misses 824 819 -5 🚀 New features to boost your workflow:
|
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
Description
With non-uniform
weights,ot.bregman.barycentergives different results depending onmethod, and only"sinkhorn_log"is correct:Evaluating the objective
sum_k w_k KL(pi_k | K)confirms that the"sinkhorn_log"result is the minimum (e.g. 33.056 against 33.169 for"sinkhorn"). Two separate problems:barycenter_sinkhorn: the updateu <- u * geometricBar(weights, UKv) / UKvleaves the weighted geometric mean ofuunchanged, so the barycenter is only optimal if it starts at 1.uwas initialised withgeometricMean(uniform weights) instead ofgeometricBar(weights, ...), so with non-uniform weights the iterations converge to a different fixed point. This is a one-line change in the initialisation.barycenter_stabilized: when absorbing, the common scalingmax_k v_kis moved intoK, butvwas then reset to ones for every histogram, which is only right when all histograms have the samev. Also, after an absorptionK.T @ uincludesexp(beta / reg), which was not taken out of the geometric mean, soqwas off by that factor. Nowvis divided by the absorbed max, andqis computed with the- beta / regcorrection.After the change the three methods agree to ~1e-11 for all the weights and
regvalues I tried, and the stabilized barycenter sums to one. The existingtest_barycenteronly usesalpha = 0.5, and atreg=1e-2with equal weights the stabilized version happened to be right, which is why these went unnoticed.How has this been tested
Added
test_barycenter_non_uniform_weights(reg1e-3 and 1e-2, weights [0.2, 0.8]), which checks that all three methods agree and sum to one. It fails on master.test_bregman.py,test/unbalanced,test_da.pyandtest_utils.pypass.Checklist