diff options
Diffstat (limited to 'ot/bregman.py')
-rw-r--r-- | ot/bregman.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/ot/bregman.py b/ot/bregman.py index b06eaeb..1deccce 100644 --- a/ot/bregman.py +++ b/ot/bregman.py @@ -108,7 +108,8 @@ def sinkhorn(a,b, M, reg, numItermax = 1000, stopThr=1e-9, verbose=False, log=Fa K = np.exp(-M/reg) #print(np.min(K)) - Kp = np.dot(np.diag(1/a),K) + Kp = (1/a).reshape(-1, 1) * K + transp = K cpt = 0 err=1 @@ -128,7 +129,7 @@ def sinkhorn(a,b, M, reg, numItermax = 1000, stopThr=1e-9, verbose=False, log=Fa break if cpt%10==0: # we can speed up the process by checking for the error only all the 10th iterations - transp = np.dot(np.diag(u),np.dot(K,np.diag(v))) + transp = u.reshape(-1, 1) * (K * v) err = np.linalg.norm((np.sum(transp,axis=0)-b))**2 if log: log['err'].append(err) |