summaryrefslogtreecommitdiff
path: root/ot/gpu
diff options
context:
space:
mode:
authorAlexandre Gramfort <alexandre.gramfort@m4x.org>2017-07-12 23:56:27 +0200
committerAlexandre Gramfort <alexandre.gramfort@m4x.org>2017-07-20 14:08:02 +0200
commit95db977e8b931277af5dadbd79eccbd5fbb8bb62 (patch)
tree4b48e558afceddfcb640e42bb0682bdcccb02b55 /ot/gpu
parent37ca3142a4c8c808382f5eb1c23bf198c3e4610e (diff)
pep8
Diffstat (limited to 'ot/gpu')
-rw-r--r--ot/gpu/bregman.py11
-rw-r--r--ot/gpu/da.py2
2 files changed, 7 insertions, 6 deletions
diff --git a/ot/gpu/bregman.py b/ot/gpu/bregman.py
index 2c3e317..7881c65 100644
--- a/ot/gpu/bregman.py
+++ b/ot/gpu/bregman.py
@@ -82,7 +82,7 @@ def sinkhorn(a, b, M_GPU, reg, numItermax=1000, stopThr=1e-9, verbose=False,
ot.lp.emd : Unregularized OT
ot.optim.cg : General regularized OT
- """
+ """
# init data
Nini = len(a)
Nfin = len(b)
@@ -92,11 +92,11 @@ def sinkhorn(a, b, M_GPU, reg, numItermax=1000, stopThr=1e-9, verbose=False,
# we assume that no distances are null except those of the diagonal of
# distances
- u = (np.ones(Nini)/Nini).reshape((Nini, 1))
+ u = (np.ones(Nini) / Nini).reshape((Nini, 1))
u_GPU = cudamat.CUDAMatrix(u)
a_GPU = cudamat.CUDAMatrix(a.reshape((Nini, 1)))
ones_GPU = cudamat.empty(u_GPU.shape).assign(1)
- v = (np.ones(Nfin)/Nfin).reshape((Nfin, 1))
+ v = (np.ones(Nfin) / Nfin).reshape((Nfin, 1))
v_GPU = cudamat.CUDAMatrix(v)
b_GPU = cudamat.CUDAMatrix(b.reshape((Nfin, 1)))
@@ -121,7 +121,7 @@ def sinkhorn(a, b, M_GPU, reg, numItermax=1000, stopThr=1e-9, verbose=False,
ones_GPU.divide(Kp_GPU.dot(v_GPU), target=u_GPU)
if (np.any(KtransposeU_GPU.asarray() == 0) or
- not u_GPU.allfinite() or not v_GPU.allfinite()):
+ not u_GPU.allfinite() or not v_GPU.allfinite()):
# we have reached the machine precision
# come back to previous solution and quit loop
print('Warning: numerical errors at iteration', cpt)
@@ -142,7 +142,8 @@ def sinkhorn(a, b, M_GPU, reg, numItermax=1000, stopThr=1e-9, verbose=False,
if verbose:
if cpt % 200 == 0:
- print('{:5s}|{:12s}'.format('It.', 'Err')+'\n'+'-'*19)
+ print(
+ '{:5s}|{:12s}'.format('It.', 'Err') + '\n' + '-' * 19)
print('{:5d}|{:8e}|'.format(cpt, err))
cpt += 1
if log:
diff --git a/ot/gpu/da.py b/ot/gpu/da.py
index b05ff70..c66e755 100644
--- a/ot/gpu/da.py
+++ b/ot/gpu/da.py
@@ -167,7 +167,7 @@ def sinkhorn_lpl1_mm(a, labels_a, b, M_GPU, reg, eta=0.1, numItermax=10,
tmpC_GPU = cudamat.empty((Nfin, nbRow)).assign(0)
transp_GPU.transpose().select_columns(indices_labels[i], tmpC_GPU)
majs_GPU = tmpC_GPU.sum(axis=1).add(epsilon)
- cudamat.pow(majs_GPU, (p-1))
+ cudamat.pow(majs_GPU, (p - 1))
majs_GPU.mult(p)
tmpC_GPU.assign(0)