summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNicolas Courty <Nico@MacBook-Pro-de-Nicolas.local>2017-09-01 11:43:51 +0200
committerNicolas Courty <Nico@MacBook-Pro-de-Nicolas.local>2017-09-01 11:43:51 +0200
commit46fc12a298c49b715ac953cff391b18b54dab0f0 (patch)
treefa40cb50af51004578b675840af6766bfd8cfe31 /examples
parent64a5d3c4e49688c13d236baf9ed23420070024d6 (diff)
solving conflicts :/
Diffstat (limited to 'examples')
-rw-r--r--examples/plot_gromov.py15
-rwxr-xr-xexamples/plot_gromov_barycenter.py33
2 files changed, 0 insertions, 48 deletions
diff --git a/examples/plot_gromov.py b/examples/plot_gromov.py
index 99aaf81..92312ae 100644
--- a/examples/plot_gromov.py
+++ b/examples/plot_gromov.py
@@ -26,11 +26,7 @@ The Gromov-Wasserstein distance allows to compute distances with samples that do
For demonstration purpose, we sample two Gaussian distributions in 2- and 3-dimensional spaces.
"""
-<<<<<<< HEAD
n_samples = 30 # nb samples
-=======
-n = 30 # nb samples
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
mu_s = np.array([0, 0])
cov_s = np.array([[1, 0], [0, 1]])
@@ -39,15 +35,9 @@ mu_t = np.array([4, 4, 4])
cov_t = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
-<<<<<<< HEAD
xs = ot.datasets.get_2D_samples_gauss(n_samples, mu_s, cov_s)
P = sp.linalg.sqrtm(cov_t)
xt = np.random.randn(n_samples, 3).dot(P) + mu_t
-=======
-xs = ot.datasets.get_2D_samples_gauss(n, mu_s, cov_s)
-P = sp.linalg.sqrtm(cov_t)
-xt = np.random.randn(n, 3).dot(P) + mu_t
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
"""
@@ -85,13 +75,8 @@ Compute Gromov-Wasserstein plans and distance
=============================================
"""
-<<<<<<< HEAD
p = ot.unif(n_samples)
q = ot.unif(n_samples)
-=======
-p = ot.unif(n)
-q = ot.unif(n)
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
gw = ot.gromov_wasserstein(C1, C2, p, q, 'square_loss', epsilon=5e-4)
gw_dist = ot.gromov_wasserstein2(C1, C2, p, q, 'square_loss', epsilon=5e-4)
diff --git a/examples/plot_gromov_barycenter.py b/examples/plot_gromov_barycenter.py
index 46ec4bc..f0657e1 100755
--- a/examples/plot_gromov_barycenter.py
+++ b/examples/plot_gromov_barycenter.py
@@ -91,21 +91,12 @@ def im2mat(I):
return I.reshape((I.shape[0] * I.shape[1], I.shape[2]))
-<<<<<<< HEAD
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
arrow = spi.imread('../data/coeur.png').astype(np.float64) / 256
shapes = [square, circle, triangle, arrow]
-=======
-carre = spi.imread('../data/carre.png').astype(np.float64) / 256
-rond = 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
-
-shapes = [carre, rond, triangle, fleche]
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
S = 4
xs = [[] for i in range(S)]
@@ -127,60 +118,36 @@ Barycenter computation
The four distributions are constructed from 4 simple images
"""
ns = [len(xs[s]) for s in range(S)]
-<<<<<<< HEAD
n_samples = 30
-=======
-N = 30
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
"""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)]
-<<<<<<< HEAD
p = ot.unif(n_samples)
-=======
-p = ot.unif(N)
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
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):
-<<<<<<< HEAD
Ct01[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[0], Cs[1]], [
-=======
- Ct01[i] = ot.gromov.gromov_barycenters(N, [Cs[0], Cs[1]], [
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
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):
-<<<<<<< HEAD
Ct02[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[0], Cs[2]], [
-=======
- Ct02[i] = ot.gromov.gromov_barycenters(N, [Cs[0], Cs[2]], [
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
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):
-<<<<<<< HEAD
Ct13[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[1], Cs[3]], [
-=======
- Ct13[i] = ot.gromov.gromov_barycenters(N, [Cs[1], Cs[3]], [
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
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):
-<<<<<<< HEAD
Ct23[i] = ot.gromov.gromov_barycenters(n_samples, [Cs[2], Cs[3]], [
-=======
- Ct23[i] = ot.gromov.gromov_barycenters(N, [Cs[2], Cs[3]], [
->>>>>>> 986f46ddde3ce2f550cb56f66620df377326423d
ps[2], ps[3]], p, lambdast[i], 'square_loss', 5e-4, numItermax=100, stopThr=1e-3)
"""