From ab6ed1df93cd78bb7f1a54282103d4d830e68bcb Mon Sep 17 00:00:00 2001 From: Nicolas Courty Date: Fri, 1 Sep 2017 11:20:34 +0200 Subject: docstrings and naming --- examples/plot_gromov_barycenter.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'examples/plot_gromov_barycenter.py') diff --git a/examples/plot_gromov_barycenter.py b/examples/plot_gromov_barycenter.py index da52768..f0657e1 100755 --- a/examples/plot_gromov_barycenter.py +++ b/examples/plot_gromov_barycenter.py @@ -91,12 +91,12 @@ def im2mat(I): return I.reshape((I.shape[0] * I.shape[1], I.shape[2])) -carre = spi.imread('../data/carre.png').astype(np.float64) / 256 -rond = spi.imread('../data/rond.png').astype(np.float64) / 256 +square = spi.imread('../data/carre.png').astype(np.float64) / 256 +circle = spi.imread('../data/rond.png').astype(np.float64) / 256 triangle = spi.imread('../data/triangle.png').astype(np.float64) / 256 -fleche = spi.imread('../data/coeur.png').astype(np.float64) / 256 +arrow = spi.imread('../data/coeur.png').astype(np.float64) / 256 -shapes = [carre, rond, triangle, fleche] +shapes = [square, circle, triangle, arrow] S = 4 xs = [[] for i in range(S)] @@ -118,36 +118,36 @@ Barycenter computation The four distributions are constructed from 4 simple images """ ns = [len(xs[s]) for s in range(S)] -N = 30 +n_samples = 30 """Compute all distances matrices for the four shapes""" Cs = [sp.spatial.distance.cdist(xs[s], xs[s]) for s in range(S)] Cs = [cs / cs.max() for cs in Cs] ps = [ot.unif(ns[s]) for s in range(S)] -p = ot.unif(N) +p = ot.unif(n_samples) lambdast = [[float(i) / 3, float(3 - i) / 3] for i in [1, 2]] Ct01 = [0 for i in range(2)] for i in range(2): - Ct01[i] = ot.gromov.gromov_barycenters(N, [Cs[0], Cs[1]], [ + Ct01[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[0], Cs[1]], [ ps[0], ps[1]], p, lambdast[i], 'square_loss', 5e-4, numItermax=100, stopThr=1e-3) Ct02 = [0 for i in range(2)] for i in range(2): - Ct02[i] = ot.gromov.gromov_barycenters(N, [Cs[0], Cs[2]], [ + Ct02[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[0], Cs[2]], [ ps[0], ps[2]], p, lambdast[i], 'square_loss', 5e-4, numItermax=100, stopThr=1e-3) Ct13 = [0 for i in range(2)] for i in range(2): - Ct13[i] = ot.gromov.gromov_barycenters(N, [Cs[1], Cs[3]], [ + Ct13[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[1], Cs[3]], [ ps[1], ps[3]], p, lambdast[i], 'square_loss', 5e-4, numItermax=100, stopThr=1e-3) Ct23 = [0 for i in range(2)] for i in range(2): - Ct23[i] = ot.gromov.gromov_barycenters(N, [Cs[2], Cs[3]], [ + Ct23[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[2], Cs[3]], [ ps[2], ps[3]], p, lambdast[i], 'square_loss', 5e-4, numItermax=100, stopThr=1e-3) """ -- cgit v1.2.3