summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/plot_OTDA_color_images.py2
-rw-r--r--examples/plot_OTDA_mapping_color_images.py2
-rw-r--r--examples/plot_optim_OTreg.py3
-rw-r--r--ot/utils.py6
-rw-r--r--test/test_gpu_sinkhorn_lpl1.py1
5 files changed, 12 insertions, 2 deletions
diff --git a/examples/plot_OTDA_color_images.py b/examples/plot_OTDA_color_images.py
index a8861c6..75ac5b6 100644
--- a/examples/plot_OTDA_color_images.py
+++ b/examples/plot_OTDA_color_images.py
@@ -48,6 +48,7 @@ def mat2im(X, shape):
"""Converts back a matrix to an image"""
return X.reshape(shape)
+
X1 = im2mat(I1)
X2 = im2mat(I2)
@@ -102,6 +103,7 @@ X2te = da_entrop.predict(X2, -1)
def minmax(I):
return np.clip(I, 0, 1)
+
I1t = minmax(mat2im(X1t, I1.shape))
I2t = minmax(mat2im(X2t, I2.shape))
diff --git a/examples/plot_OTDA_mapping_color_images.py b/examples/plot_OTDA_mapping_color_images.py
index 85c4b6b..9710461 100644
--- a/examples/plot_OTDA_mapping_color_images.py
+++ b/examples/plot_OTDA_mapping_color_images.py
@@ -48,6 +48,7 @@ def mat2im(X, shape):
"""Converts back a matrix to an image"""
return X.reshape(shape)
+
X1 = im2mat(I1)
X2 = im2mat(I2)
@@ -85,6 +86,7 @@ pl.tight_layout()
def minmax(I):
return np.clip(I, 0, 1)
+
# LP problem
da_emd = ot.da.OTDA() # init class
da_emd.fit(xs, xt) # fit distributions
diff --git a/examples/plot_optim_OTreg.py b/examples/plot_optim_OTreg.py
index e38253c..276b250 100644
--- a/examples/plot_optim_OTreg.py
+++ b/examples/plot_optim_OTreg.py
@@ -44,6 +44,7 @@ def f(G):
def df(G):
return G
+
reg = 1e-1
Gl2 = ot.optim.cg(a, b, M, reg, f, df, verbose=True)
@@ -61,6 +62,7 @@ def f(G):
def df(G):
return np.log(G) + 1.
+
reg = 1e-3
Ge = ot.optim.cg(a, b, M, reg, f, df, verbose=True)
@@ -78,6 +80,7 @@ def f(G):
def df(G):
return G
+
reg1 = 1e-3
reg2 = 1e-1
diff --git a/ot/utils.py b/ot/utils.py
index 6a43f61..1dee932 100644
--- a/ot/utils.py
+++ b/ot/utils.py
@@ -2,11 +2,13 @@
"""
Various function that can be usefull
"""
+import multiprocessing
+from functools import reduce
+import time
+
import numpy as np
from scipy.spatial.distance import cdist
-import multiprocessing
-import time
__time_tic_toc = time.time()
diff --git a/test/test_gpu_sinkhorn_lpl1.py b/test/test_gpu_sinkhorn_lpl1.py
index e6cdd31..f0eb7e6 100644
--- a/test/test_gpu_sinkhorn_lpl1.py
+++ b/test/test_gpu_sinkhorn_lpl1.py
@@ -8,6 +8,7 @@ def describeRes(r):
print("min:{:.3E}, max:{:.3E}, mean:{:.3E}, std:{:.3E}"
.format(np.min(r), np.max(r), np.mean(r), np.std(r)))
+
for n in [5000, 10000, 15000, 20000]:
print(n)
a = np.random.rand(n // 4, 100)