Repository navigation
[MRG] Fix ot.bregman.barycenter with non-uniform weights (default sinkhorn method) - #920
Open
iammanoj807 wants to merge 2 commits into
Open
iammanoj807 wants to merge 2 commits into
iammanoj807 wants to merge 2 commits into
Conversation
barycenter_sinkhorn started its scalings from the unweighted geometric mean. Its update keeps prod_k u_k ** w_k constant, so with non-uniform weights this product stayed different from 1 and the iterations converged to a point that is not the barycenter. Start from the weighted geometric mean instead.
iammanoj807
force-pushed
the
fix/barycenter-weighted-init
branch
from
November 13, 2026 21:59
c1618a9 to
e62b856
Compare
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
Bug fix:
ot.bregman.barycenter_sinkhorn, the default method ofot.bregman.barycenter, now starts its scalings from the weighted geometric mean instead of the unweighted one.Motivation and context / Related issue
Fixes #919.
The update in
barycenter_sinkhornleavesprod_k u_k ** w_kunchanged, so this product keeps its initial value for the whole run. Starting from the unweightedgeometricMean(UKv)made it equal togeometricMean(UKv) / geometricBar(weights, UKv)instead of 1. With non-uniform weights, the iterations then converge, without a warning, to a point that is not the barycenter. Starting fromgeometricBar(weights, UKv)makes the product 1. With uniform weights both means are the same, so nothing changes there.How has this been tested (if it applies)
test_barycenter_unequal_weights, forsinkhornandsinkhorn_log. It uses the setup ofplot_barycenter_1D.pywith weights[0.8, 0.2], and checks that the barycenter is centered at 28 and that the result matchessinkhorn_log.sinkhorncase fails on master, where the center is 29.11, and passes with this change.test_barycenterusesalpha = 0.5, so it could not catch this.pytest test/test_bregman.py: 102 passed, 10 skipped. Only the numpy backend is installed locally.sinkhornandsinkhorn_loggoes from 4e-2 to 3e-15. With uniform weights it stays below 6e-15, as before.ruff checkandruff format --check(0.5.2, the pre-commit version) pass on the changed files.PR checklist