From fcf23770c5ed5252dee233b578239118d9d8ba62 Mon Sep 17 00:00:00 2001 From: Laetitia Chapel Date: Mon, 20 Apr 2020 13:50:14 +0200 Subject: doc kwargs + fix rst issues --- examples/plot_partial_wass_and_gromov.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'examples') 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) -- cgit v1.2.3