summaryrefslogtreecommitdiff
path: root/ot/gpu
diff options
context:
space:
mode:
authorncassereau-idris <84033440+ncassereau-idris@users.noreply.github.com>2021-09-30 08:36:24 +0200
committerGitHub <noreply@github.com>2021-09-30 08:36:24 +0200
commit14c30d4cfac060ff0bf8c64d4c88c77df32aad86 (patch)
tree082e4b920a3cd34a29ebb3c6e6500af9f0a7fdcc /ot/gpu
parent1c7e7ce2da8bb362c184fb6eae71fe7e36356494 (diff)
[MRG] GPU bugs solve (#288)
* gpus tests now passing * pep8 compliance * GPU tests succeeding even if b has rank higher than 1 Co-authored-by: RĂ©mi Flamary <remi.flamary@gmail.com>
Diffstat (limited to 'ot/gpu')
-rw-r--r--ot/gpu/bregman.py10
-rw-r--r--ot/gpu/da.py2
2 files changed, 7 insertions, 5 deletions
diff --git a/ot/gpu/bregman.py b/ot/gpu/bregman.py
index 82f34f3..76af00e 100644
--- a/ot/gpu/bregman.py
+++ b/ot/gpu/bregman.py
@@ -54,7 +54,7 @@ def sinkhorn_knopp(a, b, M, reg, numItermax=1000, stopThr=1e-9,
numItermax : int, optional
Max number of iterations
stopThr : float, optional
- Stop threshol on error (>0)
+ Stop threshold on error (>0)
verbose : bool, optional
Print information along iterations
log : bool, optional
@@ -148,13 +148,15 @@ def sinkhorn_knopp(a, b, M, reg, numItermax=1000, stopThr=1e-9,
# we can speed up the process by checking for the error only all
# the 10th iterations
if nbb:
- err = np.sum((u - uprev)**2) / np.sum((u)**2) + \
- np.sum((v - vprev)**2) / np.sum((v)**2)
+ err = np.sqrt(
+ np.sum((u - uprev)**2) / np.sum((u)**2)
+ + np.sum((v - vprev)**2) / np.sum((v)**2)
+ )
else:
# compute right marginal tmp2= (diag(u)Kdiag(v))^T1
tmp2 = np.sum(u[:, None] * K * v[None, :], 0)
#tmp2=np.einsum('i,ij,j->j', u, K, v)
- err = np.linalg.norm(tmp2 - b)**2 # violation of marginal
+ err = np.linalg.norm(tmp2 - b) # violation of marginal
if log:
log['err'].append(err)
diff --git a/ot/gpu/da.py b/ot/gpu/da.py
index 4a98038..7adb830 100644
--- a/ot/gpu/da.py
+++ b/ot/gpu/da.py
@@ -120,7 +120,7 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M, reg, eta=0.1, numItermax=10,
labels_a2 = cp.asnumpy(labels_a)
classes = npp.unique(labels_a2)
for c in classes:
- idxc, = utils.to_gpu(npp.where(labels_a2 == c))
+ idxc = utils.to_gpu(*npp.where(labels_a2 == c))
indices_labels.append(idxc)
W = np.zeros(M.shape)