Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ot/bregman.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def sinkhorn_knopp(a, b, M, reg, numItermax=1000,
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
Expand Down
10 changes: 6 additions & 4 deletions ot/gpu/bregman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ot/gpu/da.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down