summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRĂ©mi Flamary <remi.flamary@gmail.com>2020-04-20 15:13:58 +0200
committerGitHub <noreply@github.com>2020-04-20 15:13:58 +0200
commita4426fda163d36b4970f9609007dde3d94732903 (patch)
tree75aa50b1f73931ee0152eaee2d000975243bbd32 /examples
parent470fce2b6ae01134e3e2fb7a27d9966fd776dae8 (diff)
parentf10f323bb9620850d3d28fa384e140fde91d9952 (diff)
Merge branch 'master' into laplace_da
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/plot_partial_wass_and_gromov.py24
1 files changed, 11 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)