Skip to content

Commit 952503e

Browse files
authored
Merge pull request #88 from rflamary/doc_modules
[MRG] Update documentation and add quick start guide
2 parents 8b3927b + 7402d34 commit 952503e

File tree

68 files changed

+4772
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4772
-156
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ pep8 :
4242
flake8 examples/ ot/ test/
4343

4444
test : FORCE pep8
45-
$(PYTHON) -m pytest -v test/ --cov=ot --cov-report html:cov_html
45+
$(PYTHON) -m pytest -v test/ --doctest-modules --ignore ot/gpu/ --cov=ot --cov-report html:cov_html
4646

4747
pytest : FORCE
48-
$(PYTHON) -m pytest -v test/ --cov=ot
48+
$(PYTHON) -m pytest -v test/ --doctest-modules --ignore ot/gpu/ --cov=ot
4949

5050
uploadpypi :
5151
#python setup.py register

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ The library has been tested on Linux, MacOSX and Windows. It requires a C++ comp
5454

5555
#### Pip installation
5656

57+
Note that due to a limitation of pip, `cython` and `numpy` need to be installed
58+
prior to installing POT. This can be done easily with
59+
```
60+
pip install numpy cython
61+
```
62+
5763
You can install the toolbox through PyPI with:
5864
```
5965
pip install POT
@@ -63,6 +69,8 @@ or get the very latest version by downloading it and then running:
6369
python setup.py install --user # for user install (no root)
6470
```
6571

72+
73+
6674
#### Anaconda installation with conda-forge
6775

6876
If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies:
@@ -151,7 +159,12 @@ You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.
151159

152160
## Acknowledgements
153161

154-
The contributors to this library are:
162+
This toolbox has been created and is maintained by
163+
164+
* [Rémi Flamary](http://remi.flamary.com/)
165+
* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/)
166+
167+
The contributors to this library are
155168

156169
* [Rémi Flamary](http://remi.flamary.com/)
157170
* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/)

docs/cache_nbrun

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"plot_otda_mapping_colors_images.ipynb": "cc8bf9a857f52e4a159fe71dfda19018", "plot_optim_OTreg.ipynb": "481801bb0d133ef350a65179cf8f739a", "plot_otda_color_images.ipynb": "f804d5806c7ac1a0901e4542b1eaa77b", "plot_stochastic.ipynb": "e18253354c8c1d72567a4259eb1094f7", "plot_WDA.ipynb": "27f8de4c6d7db46497076523673eedfb", "plot_otda_linear_mapping.ipynb": "a472c767abe82020e0a58125a528785c", "plot_OT_1D_smooth.ipynb": "3a059103652225a0c78ea53895cf79e5", "plot_OT_L1_vs_L2.ipynb": "5d565b8aaf03be4309eba731127851dc", "plot_barycenter_1D.ipynb": "5f6fb8aebd8e2e91ebc77c923cb112b3", "plot_otda_classes.ipynb": "39087b6e98217851575f2271c22853a4", "plot_otda_d2.ipynb": "e6feae588103f2a8fab942e5f4eff483", "plot_otda_mapping.ipynb": "2f1ebbdc0f855d9e2b7adf9edec24d25", "plot_gromov.ipynb": "24f2aea489714d34779521f46d5e2c47", "plot_compute_emd.ipynb": "f5cd71cad882ec157dc8222721e9820c", "plot_OT_1D.ipynb": "b5348bdc561c07ec168a1622e5af4b93", "plot_gromov_barycenter.ipynb": "953e5047b886ec69ec621ec52f5e21d1", "plot_free_support_barycenter.ipynb": "246dd2feff4b233a4f1a553c5a202fdc", "plot_convolutional_barycenter.ipynb": "a72bb3716a1baaffd81ae267a673f9b6", "plot_otda_semi_supervised.ipynb": "f6dfb02ba2bbd939408ffcd22a3b007c", "plot_OT_2D_samples.ipynb": "07dbc14859fa019a966caa79fa0825bd", "plot_barycenter_lp_vs_entropic.ipynb": "51833e8c76aaedeba9599ac7a30eb357"}
1+
{"plot_otda_semi_supervised.ipynb": "f6dfb02ba2bbd939408ffcd22a3b007c", "plot_WDA.ipynb": "27f8de4c6d7db46497076523673eedfb", "plot_UOT_1D.ipynb": "fc7dd383e625597bd59fff03a8430c91", "plot_OT_L1_vs_L2.ipynb": "5d565b8aaf03be4309eba731127851dc", "plot_otda_color_images.ipynb": "f804d5806c7ac1a0901e4542b1eaa77b", "plot_fgw.ipynb": "2ba3e100e92ecf4dfbeb605de20b40ab", "plot_otda_d2.ipynb": "e6feae588103f2a8fab942e5f4eff483", "plot_compute_emd.ipynb": "f5cd71cad882ec157dc8222721e9820c", "plot_barycenter_fgw.ipynb": "e14100dd276bff3ffdfdf176f1b6b070", "plot_convolutional_barycenter.ipynb": "a72bb3716a1baaffd81ae267a673f9b6", "plot_optim_OTreg.ipynb": "481801bb0d133ef350a65179cf8f739a", "plot_barycenter_lp_vs_entropic.ipynb": "51833e8c76aaedeba9599ac7a30eb357", "plot_OT_1D_smooth.ipynb": "3a059103652225a0c78ea53895cf79e5", "plot_barycenter_1D.ipynb": "5f6fb8aebd8e2e91ebc77c923cb112b3", "plot_otda_mapping.ipynb": "2f1ebbdc0f855d9e2b7adf9edec24d25", "plot_OT_1D.ipynb": "b5348bdc561c07ec168a1622e5af4b93", "plot_gromov_barycenter.ipynb": "953e5047b886ec69ec621ec52f5e21d1", "plot_UOT_barycenter_1D.ipynb": "c72f0bfb6e1a79710dad3fef9f5c557c", "plot_otda_mapping_colors_images.ipynb": "cc8bf9a857f52e4a159fe71dfda19018", "plot_stochastic.ipynb": "e18253354c8c1d72567a4259eb1094f7", "plot_otda_linear_mapping.ipynb": "a472c767abe82020e0a58125a528785c", "plot_otda_classes.ipynb": "39087b6e98217851575f2271c22853a4", "plot_free_support_barycenter.ipynb": "246dd2feff4b233a4f1a553c5a202fdc", "plot_gromov.ipynb": "24f2aea489714d34779521f46d5e2c47", "plot_OT_2D_samples.ipynb": "912a77c5dd0fc0fafa03fac3d86f1502"}
Binary file not shown.
Binary file not shown.
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

docs/source/auto_examples/index.rst

Lines changed: 100 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ This is a gallery of all the POT example files.
2929

3030
.. raw:: html
3131

32-
<div class="sphx-glr-thumbcontainer" tooltip="Illustrates the use of the generic solver for regularized OT with user-designed regularization ...">
32+
<div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the computation of Unbalanced Optimal transport using a Kullback-Leibl...">
3333

3434
.. only:: html
3535

36-
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_optim_OTreg_thumb.png
36+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_UOT_1D_thumb.png
3737

38-
:ref:`sphx_glr_auto_examples_plot_optim_OTreg.py`
38+
:ref:`sphx_glr_auto_examples_plot_UOT_1D.py`
3939

4040
.. raw:: html
4141

@@ -45,17 +45,17 @@ This is a gallery of all the POT example files.
4545
.. toctree::
4646
:hidden:
4747

48-
/auto_examples/plot_optim_OTreg
48+
/auto_examples/plot_UOT_1D
4949

5050
.. raw:: html
5151

52-
<div class="sphx-glr-thumbcontainer" tooltip="Illustration of 2D Wasserstein barycenters if discributions that are weighted sum of diracs.">
52+
<div class="sphx-glr-thumbcontainer" tooltip="Illustrates the use of the generic solver for regularized OT with user-designed regularization ...">
5353

5454
.. only:: html
5555

56-
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_free_support_barycenter_thumb.png
56+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_optim_OTreg_thumb.png
5757

58-
:ref:`sphx_glr_auto_examples_plot_free_support_barycenter.py`
58+
:ref:`sphx_glr_auto_examples_plot_optim_OTreg.py`
5959

6060
.. raw:: html
6161

@@ -65,17 +65,17 @@ This is a gallery of all the POT example files.
6565
.. toctree::
6666
:hidden:
6767

68-
/auto_examples/plot_free_support_barycenter
68+
/auto_examples/plot_optim_OTreg
6969

7070
.. raw:: html
7171

72-
<div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the computation of EMD, Sinkhorn and smooth OT plans and their visuali...">
72+
<div class="sphx-glr-thumbcontainer" tooltip="Illustration of 2D Wasserstein barycenters if discributions that are weighted sum of diracs.">
7373

7474
.. only:: html
7575

76-
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_OT_1D_smooth_thumb.png
76+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_free_support_barycenter_thumb.png
7777

78-
:ref:`sphx_glr_auto_examples_plot_OT_1D_smooth.py`
78+
:ref:`sphx_glr_auto_examples_plot_free_support_barycenter.py`
7979

8080
.. raw:: html
8181

@@ -85,17 +85,17 @@ This is a gallery of all the POT example files.
8585
.. toctree::
8686
:hidden:
8787

88-
/auto_examples/plot_OT_1D_smooth
88+
/auto_examples/plot_free_support_barycenter
8989

9090
.. raw:: html
9191

92-
<div class="sphx-glr-thumbcontainer" tooltip="This example is designed to show how to use the Gromov-Wassertsein distance computation in POT....">
92+
<div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the computation of EMD, Sinkhorn and smooth OT plans and their visuali...">
9393

9494
.. only:: html
9595

96-
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_gromov_thumb.png
96+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_OT_1D_smooth_thumb.png
9797

98-
:ref:`sphx_glr_auto_examples_plot_gromov.py`
98+
:ref:`sphx_glr_auto_examples_plot_OT_1D_smooth.py`
9999

100100
.. raw:: html
101101

@@ -105,17 +105,17 @@ This is a gallery of all the POT example files.
105105
.. toctree::
106106
:hidden:
107107

108-
/auto_examples/plot_gromov
108+
/auto_examples/plot_OT_1D_smooth
109109

110110
.. raw:: html
111111

112-
<div class="sphx-glr-thumbcontainer" tooltip="Illustration of 2D optimal transport between discributions that are weighted sum of diracs. The...">
112+
<div class="sphx-glr-thumbcontainer" tooltip="This example is designed to show how to use the Gromov-Wassertsein distance computation in POT....">
113113

114114
.. only:: html
115115

116-
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_OT_2D_samples_thumb.png
116+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_gromov_thumb.png
117117

118-
:ref:`sphx_glr_auto_examples_plot_OT_2D_samples.py`
118+
:ref:`sphx_glr_auto_examples_plot_gromov.py`
119119

120120
.. raw:: html
121121

@@ -125,7 +125,7 @@ This is a gallery of all the POT example files.
125125
.. toctree::
126126
:hidden:
127127

128-
/auto_examples/plot_OT_2D_samples
128+
/auto_examples/plot_gromov
129129

130130
.. raw:: html
131131

@@ -207,6 +207,26 @@ This is a gallery of all the POT example files.
207207

208208
/auto_examples/plot_WDA
209209

210+
.. raw:: html
211+
212+
<div class="sphx-glr-thumbcontainer" tooltip="Illustration of 2D optimal transport between discributions that are weighted sum of diracs. The...">
213+
214+
.. only:: html
215+
216+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_OT_2D_samples_thumb.png
217+
218+
:ref:`sphx_glr_auto_examples_plot_OT_2D_samples.py`
219+
220+
.. raw:: html
221+
222+
</div>
223+
224+
225+
.. toctree::
226+
:hidden:
227+
228+
/auto_examples/plot_OT_2D_samples
229+
210230
.. raw:: html
211231

212232
<div class="sphx-glr-thumbcontainer" tooltip="This example is designed to show how to use the stochatic optimization algorithms for descrete ...">
@@ -287,6 +307,26 @@ This is a gallery of all the POT example files.
287307

288308
/auto_examples/plot_otda_mapping_colors_images
289309

310+
.. raw:: html
311+
312+
<div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the computation of regularized Wassersyein Barycenter as proposed in [...">
313+
314+
.. only:: html
315+
316+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_UOT_barycenter_1D_thumb.png
317+
318+
:ref:`sphx_glr_auto_examples_plot_UOT_barycenter_1D.py`
319+
320+
.. raw:: html
321+
322+
</div>
323+
324+
325+
.. toctree::
326+
:hidden:
327+
328+
/auto_examples/plot_UOT_barycenter_1D
329+
290330
.. raw:: html
291331

292332
<div class="sphx-glr-thumbcontainer" tooltip="This example presents how to use MappingTransport to estimate at the same time both the couplin...">
@@ -327,6 +367,26 @@ This is a gallery of all the POT example files.
327367

328368
/auto_examples/plot_otda_semi_supervised
329369

370+
.. raw:: html
371+
372+
<div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the computation of FGW for 1D measures[18].">
373+
374+
.. only:: html
375+
376+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_fgw_thumb.png
377+
378+
:ref:`sphx_glr_auto_examples_plot_fgw.py`
379+
380+
.. raw:: html
381+
382+
</div>
383+
384+
385+
.. toctree::
386+
:hidden:
387+
388+
/auto_examples/plot_fgw
389+
330390
.. raw:: html
331391

332392
<div class="sphx-glr-thumbcontainer" tooltip="This example introduces a domain adaptation in a 2D setting and the 4 OTDA approaches currently...">
@@ -407,6 +467,26 @@ This is a gallery of all the POT example files.
407467

408468
/auto_examples/plot_barycenter_lp_vs_entropic
409469

470+
.. raw:: html
471+
472+
<div class="sphx-glr-thumbcontainer" tooltip="This example illustrates the computation barycenter of labeled graphs using FGW">
473+
474+
.. only:: html
475+
476+
.. figure:: /auto_examples/images/thumb/sphx_glr_plot_barycenter_fgw_thumb.png
477+
478+
:ref:`sphx_glr_auto_examples_plot_barycenter_fgw.py`
479+
480+
.. raw:: html
481+
482+
</div>
483+
484+
485+
.. toctree::
486+
:hidden:
487+
488+
/auto_examples/plot_barycenter_fgw
489+
410490
.. raw:: html
411491

412492
<div class="sphx-glr-thumbcontainer" tooltip="This example is designed to show how to use the Gromov-Wasserstein distance computation in POT....">

docs/source/auto_examples/plot_OT_2D_samples.ipynb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"# Author: Remi Flamary <[email protected]>\n#\n# License: MIT License\n\nimport numpy as np\nimport matplotlib.pylab as pl\nimport ot\nimport ot.plot"
29+
"# Author: Remi Flamary <[email protected]>\n# Kilian Fatras <[email protected]>\n#\n# License: MIT License\n\nimport numpy as np\nimport matplotlib.pylab as pl\nimport ot\nimport ot.plot"
3030
]
3131
},
3232
{
@@ -100,6 +100,24 @@
100100
"source": [
101101
"#%% sinkhorn\n\n# reg term\nlambd = 1e-3\n\nGs = ot.sinkhorn(a, b, M, lambd)\n\npl.figure(5)\npl.imshow(Gs, interpolation='nearest')\npl.title('OT matrix sinkhorn')\n\npl.figure(6)\not.plot.plot2D_samples_mat(xs, xt, Gs, color=[.5, .5, 1])\npl.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples')\npl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples')\npl.legend(loc=0)\npl.title('OT matrix Sinkhorn with samples')\n\npl.show()"
102102
]
103+
},
104+
{
105+
"cell_type": "markdown",
106+
"metadata": {},
107+
"source": [
108+
"Emprirical Sinkhorn\n----------------\n\n"
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": null,
114+
"metadata": {
115+
"collapsed": false
116+
},
117+
"outputs": [],
118+
"source": [
119+
"#%% sinkhorn\n\n# reg term\nlambd = 1e-3\n\nGes = ot.bregman.empirical_sinkhorn(xs, xt, lambd)\n\npl.figure(7)\npl.imshow(Ges, interpolation='nearest')\npl.title('OT matrix empirical sinkhorn')\n\npl.figure(8)\not.plot.plot2D_samples_mat(xs, xt, Ges, color=[.5, .5, 1])\npl.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples')\npl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples')\npl.legend(loc=0)\npl.title('OT matrix Sinkhorn from samples')\n\npl.show()"
120+
]
103121
}
104122
],
105123
"metadata": {
@@ -118,7 +136,7 @@
118136
"name": "python",
119137
"nbconvert_exporter": "python",
120138
"pygments_lexer": "ipython3",
121-
"version": "3.6.5"
139+
"version": "3.6.8"
122140
}
123141
},
124142
"nbformat": 4,

docs/source/auto_examples/plot_OT_2D_samples.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"""
1111

1212
# Author: Remi Flamary <[email protected]>
13+
# Kilian Fatras <[email protected]>
1314
#
1415
# License: MIT License
1516

@@ -100,3 +101,28 @@
100101
pl.title('OT matrix Sinkhorn with samples')
101102

102103
pl.show()
104+
105+
106+
##############################################################################
107+
# Emprirical Sinkhorn
108+
# ----------------
109+
110+
#%% sinkhorn
111+
112+
# reg term
113+
lambd = 1e-3
114+
115+
Ges = ot.bregman.empirical_sinkhorn(xs, xt, lambd)
116+
117+
pl.figure(7)
118+
pl.imshow(Ges, interpolation='nearest')
119+
pl.title('OT matrix empirical sinkhorn')
120+
121+
pl.figure(8)
122+
ot.plot.plot2D_samples_mat(xs, xt, Ges, color=[.5, .5, 1])
123+
pl.plot(xs[:, 0], xs[:, 1], '+b', label='Source samples')
124+
pl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples')
125+
pl.legend(loc=0)
126+
pl.title('OT matrix Sinkhorn from samples')
127+
128+
pl.show()

0 commit comments

Comments
 (0)