POT icon indicating copy to clipboard operation
POT copied to clipboard

[WIP] Gaussian initialization for sinkhorn

Open rflamary opened this issue 1 year ago • 3 comments

Types of changes

This is a first shot for intializing empirical sinkhorn but the computational gain is not very clear on tests I did locally.

The following code

n = 2000
rng = np.random.RandomState(0)

x = rng.randn(n, 2)
x2 = 10*rng.randn(n//2, 2)
x2[:,0]+=2


ot.tic()
G, log = ot.empirical_sinkhorn(x,x2, 1, method='sinkhorn_log', warmstart=None, verbose=False, isLazy=False, stopThr=1e-5, log = True)
ot.toc()
print("Err=",log['err'][-1], "niter=", log['niter'])

ot.tic()
G2, log2 = ot.empirical_sinkhorn(x,x2, 1, method='sinkhorn_log', warmstart='gaussian', verbose=False, isLazy=False, stopThr=1e-5, log = True)
ot.toc()
print("Err=",log2['err'][-1], "niter=", log2['niter'])

give sthe following output

Elapsed time : 3.0527355670928955 s
Err= 9.441113655553818e-06 niter= 140
Elapsed time : 2.391462564468384 s
Err= 9.89690596643644e-06 niter= 110`

Quite far from the computational gains in the paper. Will investigate it more.

Motivation and context / Related issue

How has this been tested (if it applies)

PR checklist

  • [ ] I have read the CONTRIBUTING document.
  • [ ] The documentation is up-to-date with the changes I made (check build artifacts).
  • [ ] All tests passed, and additional code has been covered with new tests.
  • [ ] I have added the PR and Issue fix to the RELEASES.md file.

rflamary avatar Nov 02 '23 16:11 rflamary

Codecov Report

Merging #555 (b3be5a6) into master (53dde7a) will decrease coverage by 12.79%. The diff coverage is 91.83%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #555       +/-   ##
===========================================
- Coverage   96.49%   83.70%   -12.79%     
===========================================
  Files          67       67               
  Lines       14663    14708       +45     
===========================================
- Hits        14149    12312     -1837     
- Misses        514     2396     +1882     

codecov[bot] avatar Nov 02 '23 16:11 codecov[bot]

I believe that your implementation is correct, i am not sure how authors handle the bias in empirical_bures_wasserstein_mapping set by default to True in POT. From the experiments in the paper I would say that gains seem specific to low regimes for the entropic regularization, did you check that ?

cedricvincentcuaz avatar Feb 26 '24 19:02 cedricvincentcuaz

will do. iI have students looking into this. Will come ack to the PR after.

rflamary avatar Feb 26 '24 20:02 rflamary