From 7bcae0fa807d67b36c44d5e0abeb45df8c65c3c6 Mon Sep 17 00:00:00 2001 From: Leo gautheron Date: Thu, 13 Apr 2017 10:53:29 +0200 Subject: update bregman file - change commented prints to python3 compatible syntax - Correct issue that could cause the sinkhorn algo to stop with u and v containing nan/infinite numbers: - Assign uprev and vprev before changing u and v. - Then update u and v. - Then check if u and v contain nan, but ALSO infinite values. - if there are issues, then display error (with 2 r, not 3 :p) along with the iteration number (there may have errors at iteration 0) --- ot/bregman.py | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/ot/bregman.py b/ot/bregman.py index 27f8ff5..b06eaeb 100644 --- a/ot/bregman.py +++ b/ot/bregman.py @@ -102,31 +102,30 @@ def sinkhorn(a,b, M, reg, numItermax = 1000, stopThr=1e-9, verbose=False, log=Fa # we assume that no distances are null except those of the diagonal of distances u = np.ones(Nini)/Nini v = np.ones(Nfin)/Nfin - uprev=np.zeros(Nini) - vprev=np.zeros(Nini) - #print reg + #print(reg) K = np.exp(-M/reg) - #print np.min(K) + #print(np.min(K)) Kp = np.dot(np.diag(1/a),K) transp = K cpt = 0 err=1 while (err>stopThr and cpt