[WIP] Wrapper for OT barycenter solvers with free support #730
[WIP] Wrapper for OT barycenter solvers with free support #730cedricvincentcuaz wants to merge 45 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #730 +/- ##
==========================================
- Coverage 96.82% 96.79% -0.04%
==========================================
Files 124 127 +3
Lines 24536 24831 +295
==========================================
+ Hits 23757 24035 +278
- Misses 779 796 +17 🚀 New features to boost your workflow:
|
rflamary
left a comment
There was a problem hiding this comment.
Some quick comments. Will have a more detailed look when solvers.py is split
|
|
||
| for i, bname in enumerate(lst_unbalanced): | ||
| for j, rname in enumerate(lst_regs): | ||
| pl.subplot(len(lst_unbalanced), len(lst_regs), i * len(lst_regs) + j + 1) |
There was a problem hiding this comment.
Maybe plot first the barycenter and belwo the barycenter + the OT plan? this is a bit dens and hard to parse visually.
rflamary
left a comment
There was a problem hiding this comment.
Thanks @cedricvincentcuaz
I took the time to go over the detailed implementation and it is very nice but found a few things. First this solver should not change the b of the bary (expect for the weird variant returned from generic) so the sum of marginal you update in the algorithm shod not be b but only a normalization term when computing barycenters.
few other comments below
|
|
||
| style.update({"markersize": 20}) | ||
|
|
||
| for i, bname in enumerate(lst_unbalanced): |
There was a problem hiding this comment.
you should do it in two pats: first sharp vs entropic baryenter (easier to compare) and then a second section where you vary the marginal violation weight so that we see the transformation from exact bary to points on the left and right (as we can see there)
Types of changes
creation of the class
ot.utils.BaryResultextendingOTResultLong term objectives: Wrap all barycenter solvers available in POT and more, ideally establishing links between these wrappers and those for inner OT solvers ot.solve_sample, ot.solve, and ot.solve_gromov - respectively associated with their barycenter solver ot.solve_bary_sample (free support); ot.solve_bary (free masses); ot.solve_bary_gromov (free joint support)
a)
ot.solvers.solve_bary_samplesystematically optimizes the support of the barycenter using BCD with closed forms if the parametermetricis in ('sqeuclidean', 'euclidean') calling an hidden function_bary_sample_bcdwhich works with most OT problems inot.solve_sample.metriccan also be a callable or a list of callable function following the API oflp.free_support_barycenter_generic_costsfor balanced OT only.b) handle variations in masses across OT problems only for unbalanced problems - keeping masses unchanged for exact and inexact sinkhorn like solvers - via parameter
update_massesinot.solvers._bary_sample_bcd.c) Handle given initialization of transport plans & potentials + warmstart strategies : added parameter
warmstarttosolve_bary_sample, and based on the requested inner OT solver, we pick the adequate strategywarmstart_planorwarmstart_potentialspassed to_bary_sample_bcd.d) Options for stopping criterion between losses and barycenter variations: added parameter
stopping_criterionin ('loss', 'bary') passed to_bary_sample_bcd.Extensions let for future works:
lst_method_lazy(in ot.solvers)How has this been tested (if it applies)
test.test_solvers.assert_allclose_bary_solmethod to compare solutions asBaryResultobjects.test_solve_bary_samplegrid across all available barycenter solvers depending on those available inot.solvers.solve_sample.test_solve_bary_sample_NotImplementedtest error messages for methods not implemented yet.test_solve_bary_sample_ValueErrorTest ValueError cases including stopping_criterion and X_b_init shape.test_solve_bary_sample_callable_metrictest barycenter solvers for balanced OT with callable metrics.PR checklist