POT : Python Optimal Transport
Repo PythonOT/POT, read from GitHub 14 min ago. PythonOT has not joined Take My Repo.
This release is identical to 0.9.7 but will allow the upload of a source distribution to PyPI and release on conda-forge (that requires a source distribution).
This release contains several bug fixes and performance improvements, as well as updates to the documentation and examples and tests. We provide below a summary of the main new features and closed issues.
New exact OT solvers. This new release adds many new variants and updates for the exact OT solver. First a new lazy exact OT solver that re-computes distances on-the-fly from coordinates, reducing memory usage from O(n×m) to O(n+m) ( available in ot.solve_sample with lazy=True)). Another major feature is the addition of a warmstart feature for the EMD solver, allowing users to provide initial potentials to speed up convergence (with init_potentials in ot.solve and ot.solve_sample). Finally the release also include a sparse solver and ot.solve now accept sparse cost matrices and provides an OT plan whose support is included in the support of the cost matrix. All implementations are backend-agnostic and preserve gradient computation for automatic differentiation (but are solved on CPU).
The computational time for different solvers (on a laptop CPU) are shown below:
| n | 100 | 500 | 1000 | 5000 |
|---|---|---|---|---|
| Solve | 7.259e-04 | 1.501e-02 | 1.055e-01 | 2.343e+00 |
| Solve Warm Start | 6.970e-04 | 5.413e-03 | 2.291e-02 | 6.036e-01 |
| Solve Lazy | 1.280e-03 | 3.098e-02 | 1.421e-01 | 3.377e+00 |
| Solve Sparse 10% | 3.453e-04 | 6.716e-04 | 1.535e-03 | 3.534e-02 |
BSPOT solver. A new solver relying on Binary Space Partitioning (BSP) has been added to compute sparse transport plans between discrete measures in loglinear time which allows for very large problems to be solved. The release also includes a new ot.unbalanced.uot_1d solver with a Frank-Wolfe solver for unbalanced optimal transport in 1D.
Sliced OT pans Finally we now have a sliced OT plan solver that can be used to compute sliced transport plans (min-pivot sliced and expected sliced) between two measures.
OT between dynamical systems. A novel Spectral-Grassmann Wasserstein metric for operator representations of dynamical systems has been implemented in ot.sgot.
Unified API for barycenter solvers in ot.solve_bary_sample. A new free support solver for barycenter solvers has been added in ot.solve_bary_sample. You can see examples of how to use it here.
OT between high dimensional Gaussian distributions. New methods to compute the linear transport map and the related 2-Wasserstein distance between high-dimensional (HD) Gaussian distributions have been added in ot.gaussian.bures_wasserstein_mapping_hd and ot.gaussian.bures_wasserstein_distance_hd, respectively with empirical versions that estimate the distance from sample.
Batched solver for exact OT. The batch implementations have also been improved and you can now solve exact OT problems in parallel on CPU or GPU using the new proximal point solver in functions ot.solve_batch and ot.solve_sample_batch when reg=0 or no provided. A new batch loss for Fused unbalanced Gromov-Wasserstein is also now available in ot.batch.
New methods in unified API ot.solve_sample. The unified API function
ot.solve_sample has also been updated to allows solving of specific problems such as BSP-OT, distance between high-dimensional (HD) Gaussian distributions and sliced and max-sliced distances.
Data normalization for sliced and ot.solve_sample solvers. The release also includes tools for data normalization and scaling which can not be used in sliced Wasserstein distance computations. A simple normalization class ot.utils.DataScaler has been added and supports all backends for 'standard', 'minmax', and 'l2' methods. Finally an optional scaler parameter has been added to ot.sliced_wasserstein_distance, ot.max_sliced_wasserstein_distance and ot.solve_sample.
scipy.sparse.coo_matrix to modern scipy.sparse.coo_array (PR #782)ot.unbalanced.uot_1d (PR #765)ot/unbalanced/_sliced.py (PR #765)ot.utils.DataScaler class for backend-aware joint normalization of input distributions, with sklearn-compatible fit/transform/fit_transform API and support for 'standard', 'minmax', and 'l2' methods (PR #808)ot.utils.apply_scaler helper that dispatches preprocessing to a scaler object,scaler parameter to sliced_wasserstein_distance and max_sliced_wasserstein_distance (PR #808)ot.semidiscrete and a gallery example. (PR #812)method parameter of entropic_partial_wasserstein (method='sinkhorn_log') or directly through entropic_partial_wasserstein_logscale (Issue #723)ot.sgot (PR #792, PR #830)ot.batch and fix issues in some default parameters in the batch module (PR #775)ot.solvers.bary_free_support (PR #730)ot.gaussian.bures_wasserstein_mapping_hd and ot.gaussian.bures_wasserstein_distance_hd, respectively. Two additional methods estimate the same quantities from the source and destination observed data and are implemented in ot.gaussian.empirical_bures_wasserstein_mapping_hd and ot.gaussian.empirical_bures_wasserstein_distance_hd, respectively (PR #814)lowrank_gromov_wasserstein_samples and lowrank_sinkhorn (PR #823)ot.batch.proximal_bregman_log_plan_batch function and updated wrapper functions ot.batch.solve_batch and ot.batch.solve_sample_batch (PR #832)ot.solve_sample.ot.da transport classes: the large cost was applied to unlabeled pairs instead of labeled pairs with different labels, so ys/yt had no effect when all labels were known (PR #833, Issue #664)entropic_partial_wasserstein at small reg via a new log-domain solver, reachable with entropic_partial_wasserstein(..., method='sinkhorn_log') (Issue #723; the default method='sinkhorn' path is unchanged — callers opt into the log-domain variant)ot.backend.JaxBackend (PR #771, Issue #770)ot.batch (PR #784, Issue #783)ot.backend (PR #794)gcg(PR #817, Issue #758)This is a bug fix release because a Cython file was missing form the previous source release (all wheels work fine)
This new release contains several new features and bug fixes. Among the new features we have a new submodule ot.batch that contains batch parallel solvers for several OT problems including Sinkhorn, Gromov-Wasserstein and Fused Gromov-Wasserstein. This new submodule can be used to solve many independent OT problems in parallel on CPU or GPU with shared source and target support sizes. We also implemented a new Nystrom kernel approximation for the Sinkhorn solver that can be used to speed up the computation of the Sinkhorn divergence on large datasets. We also added new 1D solvers for Linear circular OT and new solvers for free support OT barycenters with generic cost functions and for barycenters between Gaussian Mixture Models (GMMs). We also implemented two solvers for partial Fused Gromov-Wasserstein problems based on conditional gradient and projected gradient descents.
Finally we have updated the documentation to reflect the new generic API and reorganized the examples gallery.
grad=last_step for ot.solvers.solve (PR #693)ot/lp/__init__.py into separate files (PR #714)ot.lp.free_support_barycenter), with example. (PR #715)ot.gaussian (PR #718)ot.bregman._convolutional to improve readability (PR #709)ot.gaussian.bures_barycenter_gradient_descent (PR #680)ot.gaussian.bures_wasserstein_distance (PR #680)ot.gaussian.bures_wasserstein_distance can be batched (PR #680)ot.dist for (PR #701)ot.solver_1d.linear_circular_ot and ot.sliced.linear_sliced_wasserstein_sphere (PR #736)ot.unbalanced.lbfgsb_unbalanced via new function ot.utils.fun_to_numpy (PR #731)ot.mapping solvers which depended on deprecated cvxpy ECOS solver (PR #692, Issue #668)ot.gmm (PR #690, Issue #689)ot.unbalanced sinkhorn solvers (Issue #691, PR #700)gromov, lp and unbalanced folders (PR #710)ot.gromov.gromov_wasserstein (PR #737)ot.lp.solver_1d.wasserstein_circle (Issue #738)ot.lp.solver_1d.binary_search_circle (Issue #738)ot.lp.solver_1d.wasserstein_1d (Issue #760, PR #761)Full Changelog: 0.9.5...0.9.6
This new release contains several new features, starting with a novel Gaussian Mixture Model Optimal Transport (GMM-OT) solver to compare GMM while enforcing the transport plan to remain a GMM, that benefits from a closed-form solution making it practical for high-dimensional matching problems. We also extended our general unbalanced OT solvers to support any non-negative reference measure in the regularization terms, before adding the novel translation invariant UOT solver showcasing a higher convergence speed.
We also implemented several new solvers and enhanced existing ones to perform OT across spaces. These include a semi-relaxed FGW barycenter solver, coupled with new initialization heuristics for the inner divergence computation, to perform graph partitioning or dictionary learning. Followed by novel unbalanced FGW and Co-optimal transport solvers to promote robustness to outliers in such matching problems. And we finally updated the implementation of partial GW now supporting asymmetric structures and the KL divergence, while leveraging a new generic conditional gradient solver for partial transport problems enabling significant speed improvements. These latest updates required some modifications to the line search functions of our generic conditional gradient solver, paving the way for future improvements to other GW-based solvers.
Last but not least, we implemented a pre-commit scheme to automatically correct common programming mistakes likely to be made by our future contributors.
This release also contains few bug fixes, concerning the support of any metric in ot.emd_1d / ot.emd2_1d, and the support of any weights in ot.gaussian.
line_search to ot.optim.generic_conditional_gradient must now have the signature line_search(cost, G, deltaG, Mi, cost_G, df_G, **kwargs), adding as input df_G the gradient of the regularizer evaluated at the transport plan G. This change aims at improving speed of solvers having quadratic polynomial functions as regularizer such as the Gromov-Wassertein loss (PR #663).mass=True for nx.kl_div (PR #654)ot.gmm (PR #649)semirelaxed_fgw_barycenters and generic FGW-related barycenter updates update_barycenter_structure and update_barycenter_feature (PR #659)semirelaxed_init_plan, integrated in all sr(F)GW solvers (PR #659)ot.plot.plot1D_mat (PR #649)nx.det (PR #649)nx.sqrtm is now broadcastable (takes ..., d, d) inputs (PR #649)ot.unbalanced module (PR #658)ot.unbalanced.lbfgsb_unbalanced2 and add flexible reference measure c in all unbalanced solvers (PR #658)ot.partial moved to ot.gromov (PR #663)ot.gromov._partial add new features loss_fun = "kl_loss" and symmetry=False to all solvers while increasing speed + updating adequatly ot.solvers (PR #663)ot.unbalanced.sinkhorn_unbalanced_translation_invariant (PR #676)ot.gaussian ignoring weights when computing means (PR #649, Issue #648)ot.emd_1d and ot.emd2_1d incorrectly allowing any metric (PR #670, Issue #669)Full Changelog: 0.9.4...0.9.5
This new release contains several new features and bug fixes. Among the new features
we have novel Quantized FGW solvers that can be used to speed up the computation of the FGW loss on large datasets or to promote a structure on the pairwise matrices. We also updated the continuous entropic mapping to provide efficient out-of-sample continuous mapping thanks to entropic regularization. We also have a new general unbalanced solvers for ot.solve and BFGS solver and illustrative example. Finally we have a new solver for the Low Rank Gromov-Wasserstein that can be used to compute the GW distance between two large scale datasets with a low rank approximation.
From a maintenance point of view, we now have a new option to install optional dependencies with pip install POT[all] and the specific backends or submodules' dependencies may also be installed individually. The pip options are: backend-jax, backend-tf, backend-torch, cvxopt, dr, gnn, plot, all. We also provide with this release support for NumPy 2.0 (the wheels should now be compatible with NumPy 2.0 and below). We also fixed several issues such as gradient sign errors for FGW solvers, empty weights for ot.emd2, and line-search in partial GW. We also split the test/test_gromov.py into test/gromov/ to make the tests more manageable.
ot.gromov.quantized_fused_gromov_wasserstein, ot.gromov.quantized_fused_gromov_wasserstein_samples and ot.gromov.quantized_fused_gromov_wasserstein_partitioned (PR #603)ot.gromov._gw.solve_gromov_linesearch now has an argument to specify if the matrices are symmetric in which case the computation can be done faster (PR #607).ot.solve and BFGS solver and illustrative example (PR #620)ot.solve with grad='envelope' (PR #605).ot.gromov.lowrank_gromov_wasserstein_samples (PR #614)pip install POT[all] The specific backends or submodules' dependencies may also be installed individually. The pip options are: backend-jax, backend-tf, backend-torch, cvxopt, dr, gnn, all. The installation of the cupy backend should be done with conda.G0 is not None(PR #596)ot.emd2 (PR #606, Issue #534)ot.gromov._gw.fused_gromov_wasserstein2 and ot.gromov._gw.gromov_wasserstein2 for the kl loss (PR #610)test/test_gromov.py into test/gromov/ (PR #619)ot.da.sinkhorn_lpl1_mm compatibility with JAX (PR #592)Full Changelog: 0.9.3...0.9.4