diff options
-rwxr-xr-x | examples/plot_partial_wass_and_gromov.py | 24 | ||||
-rwxr-xr-x | ot/partial.py | 6 |
2 files changed, 17 insertions, 13 deletions
diff --git a/examples/plot_partial_wass_and_gromov.py b/examples/plot_partial_wass_and_gromov.py index 30b3fc0..a5af441 100755 --- a/examples/plot_partial_wass_and_gromov.py +++ b/examples/plot_partial_wass_and_gromov.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*-
"""
-==========================
+==================================================
Partial Wasserstein and Gromov-Wasserstein example
-==========================
+==================================================
This example is designed to show how to use the Partial (Gromov-)Wassertsein
distance computation in POT.
@@ -50,8 +50,7 @@ pl.show() #############################################################################
#
-# Compute partial Wasserstein plans and distance,
-# by transporting 50% of the mass
+# Compute partial Wasserstein plans and distance
# ----------------------------------------------
p = ot.unif(n_samples + n_noise)
@@ -113,34 +112,33 @@ pl.show() #############################################################################
#
-# Compute partial Gromov-Wasserstein plans and distance,
-# by transporting 100% and 2/3 of the mass
+# Compute partial Gromov-Wasserstein plans and distance
# -----------------------------------------------------
C1 = sp.spatial.distance.cdist(xs, xs)
C2 = sp.spatial.distance.cdist(xt, xt)
+# transport 100% of the mass
print('-----m = 1')
m = 1
-res0, log0 = ot.partial.partial_gromov_wasserstein(C1, C2, p, q, m=m,
- log=True)
+res0, log0 = ot.partial.partial_gromov_wasserstein(C1, C2, p, q, m=m, log=True)
res, log = ot.partial.entropic_partial_gromov_wasserstein(C1, C2, p, q, 10,
m=m, log=True)
-print('Partial Wasserstein distance (m = 1): ' + str(log0['partial_gw_dist']))
-print('Entropic partial Wasserstein distance (m = 1): ' +
- str(log['partial_gw_dist']))
+print('Wasserstein distance (m = 1): ' + str(log0['partial_gw_dist']))
+print('Entropic Wasserstein distance (m = 1): ' + str(log['partial_gw_dist']))
pl.figure(1, (10, 5))
pl.title("mass to be transported m = 1")
pl.subplot(1, 2, 1)
pl.imshow(res0, cmap='jet')
-pl.title('Partial Wasserstein')
+pl.title('Wasserstein')
pl.subplot(1, 2, 2)
pl.imshow(res, cmap='jet')
-pl.title('Entropic partial Wasserstein')
+pl.title('Entropic Wasserstein')
pl.show()
+# transport 2/3 of the mass
print('-----m = 2/3')
m = 2 / 3
res0, log0 = ot.partial.partial_gromov_wasserstein(C1, C2, p, q, m=m, log=True)
diff --git a/ot/partial.py b/ot/partial.py index 5f4b836..c03ec25 100755 --- a/ot/partial.py +++ b/ot/partial.py @@ -66,6 +66,8 @@ def partial_wasserstein_lagrange(a, b, M, reg_m=None, nb_dummies=1, log=False, instabilities, increase its value if an error is raised) log : bool, optional record log if True + **kwargs : dict + parameters can be directly passed to the emd solver .. warning:: When dealing with a large number of points, the EMD solver may face @@ -190,6 +192,8 @@ def partial_wasserstein(a, b, M, m=None, nb_dummies=1, log=False, **kwargs): instabilities, increase its value if an error is raised) log : bool, optional record log if True + **kwargs : dict + parameters can be directly passed to the emd solver .. warning:: @@ -304,6 +308,8 @@ def partial_wasserstein2(a, b, M, m=None, nb_dummies=1, log=False, **kwargs): instabilities, increase its value if an error is raised) log : bool, optional record log if True + **kwargs : dict + parameters can be directly passed to the emd solver .. warning:: |