Skip to content

[MRG] add screenkhorn: screening Sinkhorn algorithm #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3582b6f
add screenkhorn: screening Sinkhorn algorithm
mzalaya Jan 6, 2020
d4b403e
close "bottleneck" tag
mzalaya Jan 7, 2020
3979fe9
update readme
mzalaya Jan 7, 2020
0d33c3f
update readme
mzalaya Jan 7, 2020
e11dbad
update README
mzalaya Jan 7, 2020
4488a0b
update README
mzalaya Jan 7, 2020
e821872
update README
mzalaya Jan 7, 2020
27b6740
improve documentation of screenkhorn
mzalaya Jan 7, 2020
7d603f0
delete "ArrayBox"-type test of dist. matrix M
mzalaya Jan 7, 2020
be33a36
replace @ operator by np.dot
mzalaya Jan 7, 2020
69c666f
set default param. for LBFGS in the function's prototype
mzalaya Jan 7, 2020
05a97b4
fix default values for the budget arguments
mzalaya Jan 7, 2020
92b7075
replace reshape by numpy slicing in return
mzalaya Jan 7, 2020
cfe2614
fix definitions complementary active sets Ic, Jc
mzalaya Jan 7, 2020
88fb534
fix typos in documentation
mzalaya Jan 7, 2020
4511960
using binary indexing for definition the active sets
mzalaya Jan 8, 2020
e00f46a
fix binary indexing
Jan 8, 2020
3e77515
add illustration for screenkhorn
Jan 8, 2020
112a2d4
plot_screenkhorn_1D.ipynb
Jan 8, 2020
73de285
improve documentation
Jan 10, 2020
5a70afe
update screenkhorn example
Jan 10, 2020
cadd301
improve doc
Jan 10, 2020
0461fb5
improve doc
Jan 10, 2020
365adbc
add simple test for screenkhorn
Jan 10, 2020
1824243
fix simple test of screenkhorn in test/
Jan 13, 2020
4918d2c
update readme
Jan 16, 2020
936b5e1
update
Jan 16, 2020
0f75310
clean
Jan 18, 2020
55e4f76
remove .idea/POT.iml
Jan 18, 2020
3be0c21
clean
Jan 18, 2020
b3fb1ef
clean
Jan 18, 2020
7f7b1c5
make autopep
Jan 18, 2020
a1747a1
make autopep
Jan 18, 2020
7c25e07
clean
Jan 18, 2020
b6fa567
clean
Jan 18, 2020
bfde1ac
Merge branch 'master' into master
rflamary Jan 22, 2020
e92b707
add a warning for non installed Botteleneck module
Jan 24, 2020
c5b1c7c
modify pymanopt version in requirements
Jan 24, 2020
cae3979
modify pymanopt version in requirements
Jan 24, 2020
6d4ccac
modify pymanopt version in requirements
Jan 24, 2020
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ It provides the following solvers:
* Stochastic Optimization for Large-scale Optimal Transport (semi-dual problem [18] and dual problem [19])
* Non regularized free support Wasserstein barycenters [20].
* Unbalanced OT with KL relaxation distance and barycenter [10, 25].
* Screening Sinkhorn Algorithm for OT [26].

Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder.

Expand Down Expand Up @@ -180,6 +181,7 @@ The contributors to this library are
* [Vayer Titouan](https://tvayer.github.io/)
* [Hicham Janati](https://hichamjanati.github.io/) (Unbalanced OT)
* [Romain Tavenard](https://rtavenar.github.io/) (1d Wasserstein)
* [Mokhtar Z. Alaya](http://mzalaya.github.io/) (Screenkhorn)

This toolbox benefit a lot from open source research and we would like to thank the following persons for providing some code (in various languages):

Expand Down Expand Up @@ -252,4 +254,6 @@ You can also post bug reports and feature requests in Github issues. Make sure t

[24] Vayer, T., Chapel, L., Flamary, R., Tavenard, R. and Courty, N. (2019). [Optimal Transport for structured data with application on graphs](http://proceedings.mlr.press/v97/titouan19a.html) Proceedings of the 36th International Conference on Machine Learning (ICML).

[25] Frogner C., Zhang C., Mobahi H., Araya-Polo M., Poggio T. (2019). [Learning with a Wasserstein Loss](http://cbcl.mit.edu/wasserstein/) Advances in Neural Information Processing Systems (NIPS).
[25] Frogner C., Zhang C., Mobahi H., Araya-Polo M., Poggio T. (2015). [Learning with a Wasserstein Loss](http://cbcl.mit.edu/wasserstein/) Advances in Neural Information Processing Systems (NIPS).

[26] Alaya M. Z., Bérar M., Gasso G., Rakotomamonjy A. (2019). [Screening Sinkhorn Algorithm for Regularized Optimal Transport](https://papers.nips.cc/paper/9386-screening-sinkhorn-algorithm-for-regularized-optimal-transport), Advances in Neural Information Processing Systems 33 (NeurIPS).
68 changes: 68 additions & 0 deletions examples/plot_screenkhorn_1D.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
"""
===============================
1D Screened optimal transport
===============================

This example illustrates the computation of Screenkhorn:
Screening Sinkhorn Algorithm for Optimal transport.
"""

# Author: Mokhtar Z. Alaya <mokhtarzahdi.alaya@gmail.com>
#
# License: MIT License

import numpy as np
import matplotlib.pylab as pl
import ot.plot
from ot.datasets import make_1D_gauss as gauss
from ot.bregman import screenkhorn

##############################################################################
# Generate data
# -------------

#%% parameters

n = 100 # nb bins

# bin positions
x = np.arange(n, dtype=np.float64)

# Gaussian distributions
a = gauss(n, m=20, s=5) # m= mean, s= std
b = gauss(n, m=60, s=10)

# loss matrix
M = ot.dist(x.reshape((n, 1)), x.reshape((n, 1)))
M /= M.max()

##############################################################################
# Plot distributions and loss matrix
# ----------------------------------

#%% plot the distributions

pl.figure(1, figsize=(6.4, 3))
pl.plot(x, a, 'b', label='Source distribution')
pl.plot(x, b, 'r', label='Target distribution')
pl.legend()

# plot distributions and loss matrix

pl.figure(2, figsize=(5, 5))
ot.plot.plot1D_mat(a, b, M, 'Cost matrix M')

##############################################################################
# Solve Screenkhorn
# -----------------------

# Screenkhorn
lambd = 2e-03 # entropy parameter
ns_budget = 30 # budget number of points to be keeped in the source distribution
nt_budget = 30 # budget number of points to be keeped in the target distribution

G_screen = screenkhorn(a, b, M, lambd, ns_budget, nt_budget, uniform=False, restricted=True, verbose=True)
pl.figure(4, figsize=(5, 5))
ot.plot.plot1D_mat(a, b, G_screen, 'OT matrix Screenkhorn')
pl.show()
Loading