From 93785eba11b59d544f1edde6661e93ee587148ee Mon Sep 17 00:00:00 2001 From: Laetitia Chapel Date: Thu, 22 Oct 2020 10:58:31 +0200 Subject: [MRG] Fix bugs for partial OT (#215) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bugfix * update refs partial OT * fixes small typos in plot_partial_wass_and_gromov * fix small bugs in partial.py * update README * pep8 bugfix * modif doctest * fix bugtests * update on test_partial and test on the numerical precision on ot/partial * resolve merge pb Co-authored-by: RĂ©mi Flamary --- .../plot_partial_wass_and_gromov.py | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'examples/unbalanced-partial/plot_partial_wass_and_gromov.py') diff --git a/examples/unbalanced-partial/plot_partial_wass_and_gromov.py b/examples/unbalanced-partial/plot_partial_wass_and_gromov.py index 0c5cbf9..ac4194c 100755 --- a/examples/unbalanced-partial/plot_partial_wass_and_gromov.py +++ b/examples/unbalanced-partial/plot_partial_wass_and_gromov.py @@ -4,7 +4,7 @@ Partial Wasserstein and Gromov-Wasserstein example ================================================== -This example is designed to show how to use the Partial (Gromov-)Wassertsein +This example is designed to show how to use the Partial (Gromov-)Wasserstein distance computation in POT. """ @@ -123,11 +123,12 @@ C1 = sp.spatial.distance.cdist(xs, xs) C2 = sp.spatial.distance.cdist(xt, xt) # transport 100% of the mass -print('-----m = 1') +print('------m = 1') m = 1 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) + m=m, log=True, + verbose=True) print('Wasserstein distance (m = 1): ' + str(log0['partial_gw_dist'])) print('Entropic Wasserstein distance (m = 1): ' + str(log['partial_gw_dist'])) @@ -136,18 +137,20 @@ 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('Wasserstein') +pl.title('Gromov-Wasserstein') pl.subplot(1, 2, 2) pl.imshow(res, cmap='jet') -pl.title('Entropic Wasserstein') +pl.title('Entropic Gromov-Wasserstein') pl.show() # transport 2/3 of the mass -print('-----m = 2/3') +print('------m = 2/3') m = 2 / 3 -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, + verbose=True) res, log = ot.partial.entropic_partial_gromov_wasserstein(C1, C2, p, q, 10, - m=m, log=True) + m=m, log=True, + verbose=True) print('Partial Wasserstein distance (m = 2/3): ' + str(log0['partial_gw_dist'])) @@ -158,8 +161,8 @@ pl.figure(1, (10, 5)) pl.title("mass to be transported m = 2/3") pl.subplot(1, 2, 1) pl.imshow(res0, cmap='jet') -pl.title('Partial Wasserstein') +pl.title('Partial Gromov-Wasserstein') pl.subplot(1, 2, 2) pl.imshow(res, cmap='jet') -pl.title('Entropic partial Wasserstein') +pl.title('Entropic partial Gromov-Wasserstein') pl.show() -- cgit v1.2.3