From 3e7eb430ddf59cc2a6bbd2ada29ac22c9d31cd05 Mon Sep 17 00:00:00 2001 From: Nicolas Courty Date: Fri, 7 Sep 2018 15:13:44 +0200 Subject: test wasserstein barycenter --- test/test_bregman.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/test_bregman.py b/test/test_bregman.py index c8e9179..01ec655 100644 --- a/test/test_bregman.py +++ b/test/test_bregman.py @@ -105,6 +105,30 @@ def test_bary(): ot.bregman.barycenter(A, M, reg, log=True, verbose=True) +def test_wassersteinbary(): + + size = 100 # size of a square image + a1 = np.random.randn(size, size) + a1 += a1.min() + a1 = a1 / np.sum(a1) + a2 = np.random.randn(size, size) + a2 += a2.min() + a2 = a2 / np.sum(a2) + # creating matrix A containing all distributions + A = np.zeros((2, 100, 100)) + A[0, :, :] = a1 + A[1, :, :] = a2 + + # wasserstein + reg = 1e-3 + bary_wass = ot.bregman.convolutional_barycenter2d(A, reg) + + np.testing.assert_allclose(1, np.sum(bary_wass)) + + # help in checking if log and verbose do not bug the function + ot.bregman.convolutional_barycenter2d(A, reg, log=True, verbose=True) + + def test_unmix(): n_bins = 50 # nb bins -- cgit v1.2.3 From 7786e8502ea010a52918861014ab0e7a934a7d45 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Fri, 14 Sep 2018 08:58:56 +0200 Subject: correct path function in example --- test/test_stochastic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_stochastic.py b/test/test_stochastic.py index 0128317..62cf82a 100644 --- a/test/test_stochastic.py +++ b/test/test_stochastic.py @@ -92,7 +92,7 @@ def test_sag_asgd_sinkhorn(): # test all algorithms n = 15 reg = 1 - nb_iter = 300000 + nb_iter = 30000 rng = np.random.RandomState(0) x = rng.randn(n, 2) @@ -167,7 +167,7 @@ def test_dual_sgd_sinkhorn(): # test all dual algorithms n = 10 reg = 1 - nb_iter = 150000 + nb_iter = 15000 batch_size = 10 rng = np.random.RandomState(0) -- cgit v1.2.3 From ccbe274fd9554492bb88ddaf530c2800a8dc3418 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Fri, 14 Sep 2018 09:03:07 +0200 Subject: speedup test stochastic --- test/test_stochastic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test_stochastic.py b/test/test_stochastic.py index 62cf82a..f0f3fc8 100644 --- a/test/test_stochastic.py +++ b/test/test_stochastic.py @@ -32,7 +32,7 @@ def test_stochastic_sag(): # test sag n = 15 reg = 1 - numItermax = 300000 + numItermax = 30000 rng = np.random.RandomState(0) x = rng.randn(n, 2) @@ -62,7 +62,7 @@ def test_stochastic_asgd(): # test asgd n = 15 reg = 1 - numItermax = 300000 + numItermax = 100000 rng = np.random.RandomState(0) x = rng.randn(n, 2) @@ -92,7 +92,7 @@ def test_sag_asgd_sinkhorn(): # test all algorithms n = 15 reg = 1 - nb_iter = 30000 + nb_iter = 100000 rng = np.random.RandomState(0) x = rng.randn(n, 2) -- cgit v1.2.3