You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This open source Python library provide several solvers for optimization
13
12
problems related to Optimal Transport for signal, image processing and machine
14
13
learning.
@@ -51,13 +50,15 @@ Some other examples are available in the [documentation](https://pythonot.githu
51
50
52
51
If you use this toolbox in your research and find it useful, please cite POT
53
52
using the following reference from our [JMLR paper](https://jmlr.org/papers/v22/20-451.html):
54
-
```
55
-
Rémi Flamary, Nicolas Courty, Alexandre Gramfort, Mokhtar Z. Alaya, Aurélie Boisbunon, Stanislas Chambon, Laetitia Chapel, Adrien Corenflos, Kilian Fatras, Nemo Fournier, Léo Gautheron, Nathalie T.H. Gayraud, Hicham Janati, Alain Rakotomamonjy, Ievgen Redko, Antoine Rolet, Antony Schutz, Vivien Seguy, Danica J. Sutherland, Romain Tavenard, Alexander Tong, Titouan Vayer;, POT Python Optimal Transport library, Journal of Machine Learning Research, 22(78):1−8, 2021.
56
-
Website: https://pythonot.github.io/
57
-
```
53
+
54
+
Rémi Flamary, Nicolas Courty, Alexandre Gramfort, Mokhtar Z. Alaya, Aurélie Boisbunon, Stanislas Chambon, Laetitia Chapel, Adrien Corenflos, Kilian Fatras, Nemo Fournier, Léo Gautheron, Nathalie T.H. Gayraud, Hicham Janati, Alain Rakotomamonjy, Ievgen Redko, Antoine Rolet, Antony Schutz, Vivien Seguy, Danica J. Sutherland, Romain Tavenard, Alexander Tong, Titouan Vayer,
55
+
POT Python Optimal Transport library,
56
+
Journal of Machine Learning Research, 22(78):1−8, 2021.
57
+
Website: https://pythonot.github.io/
58
58
59
59
In Bibtex format:
60
-
```
60
+
61
+
```bibtex
61
62
@article{flamary2021pot,
62
63
author = {R{\'e}mi Flamary and Nicolas Courty and Alexandre Gramfort and Mokhtar Z. Alaya and Aur{\'e}lie Boisbunon and Stanislas Chambon and Laetitia Chapel and Adrien Corenflos and Kilian Fatras and Nemo Fournier and L{\'e}o Gautheron and Nathalie T.H. Gayraud and Hicham Janati and Alain Rakotomamonjy and Ievgen Redko and Antoine Rolet and Antony Schutz and Vivien Seguy and Danica J. Sutherland and Romain Tavenard and Alexander Tong and Titouan Vayer},
63
64
title = {POT: Python Optimal Transport},
@@ -83,33 +84,38 @@ The library has been tested on Linux, MacOSX and Windows. It requires a C++ comp
83
84
84
85
Note that due to a limitation of pip, `cython` and `numpy` need to be installed
85
86
prior to installing POT. This can be done easily with
86
-
```
87
+
88
+
```console
87
89
pip install numpy cython
88
90
```
89
91
90
92
You can install the toolbox through PyPI with:
91
-
```
93
+
94
+
```console
92
95
pip install POT
93
96
```
97
+
94
98
or get the very latest version by running:
95
-
```
99
+
100
+
```console
96
101
pip install -U https://github.com/PythonOT/POT/archive/master.zip # with --user for user install (no root)
97
102
```
98
103
99
-
100
-
101
104
#### Anaconda installation with conda-forge
102
105
103
106
If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies:
104
-
```
107
+
108
+
```console
105
109
conda install -c conda-forge pot
106
110
```
107
111
108
112
#### Post installation check
109
113
After a correct installation, you should be able to import the module without errors:
114
+
110
115
```python
111
116
import ot
112
117
```
118
+
113
119
Note that for easier access the module is name ot instead of pot.
114
120
115
121
@@ -118,42 +124,48 @@ Note that for easier access the module is name ot instead of pot.
118
124
Some sub-modules require additional dependences which are discussed below
119
125
120
126
***ot.dr** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with:
121
-
```
127
+
128
+
```shell
122
129
pip install pymanopt autograd
123
130
```
124
-
***ot.gpu** (GPU accelerated OT) depends on cupy that have to be installed following instructions on [this page](https://docs-cupy.chainer.org/en/stable/install.html).
125
131
126
-
127
-
obviously you need CUDA installed and a compatible GPU.
132
+
***ot.gpu** (GPU accelerated OT) depends on cupy that have to be installed following instructions on [this page](https://docs-cupy.chainer.org/en/stable/install.html). Obviously you will need CUDA installed and a compatible GPU.
128
133
129
134
## Examples
130
135
131
136
### Short examples
132
137
133
138
* Import the toolbox
139
+
134
140
```python
135
141
import ot
136
142
```
143
+
137
144
* Compute Wasserstein distances
145
+
138
146
```python
139
147
# a,b are 1D histograms (sum to 1 and positive)
140
148
# M is the ground cost matrix
141
-
Wd=ot.emd2(a,b,M) # exact linear program
142
-
Wd_reg=ot.sinkhorn2(a,b,M,reg) # entropic regularized OT
149
+
Wd=ot.emd2(a, b, M) # exact linear program
150
+
Wd_reg=ot.sinkhorn2(a, b, M, reg) # entropic regularized OT
143
151
# if b is a matrix compute all distances to a and return a vector
144
152
```
153
+
145
154
* Compute OT matrix
155
+
146
156
```python
147
157
# a,b are 1D histograms (sum to 1 and positive)
148
158
# M is the ground cost matrix
149
-
T=ot.emd(a,b,M) # exact linear program
150
-
T_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT
159
+
T=ot.emd(a, b, M) # exact linear program
160
+
T_reg=ot.sinkhorn(a, b, M, reg) # entropic regularized OT
151
161
```
162
+
152
163
* Compute Wasserstein barycenter
164
+
153
165
```python
154
166
# A is a n*d matrix containing d 1D histograms
155
167
# M is the ground cost matrix
156
-
ba=ot.barycenter(A,M,reg) # reg is regularization parameter
168
+
ba=ot.barycenter(A, M, reg) # reg is regularization parameter
157
169
```
158
170
159
171
### Examples and Notebooks
@@ -194,7 +206,6 @@ This toolbox benefit a lot from open source research and we would like to thank
194
206
*[Nicolas Bonneel](http://liris.cnrs.fr/~nbonneel/) ( C++ code for EMD)
195
207
*[Marco Cuturi](http://marcocuturi.net/) (Sinkhorn Knopp in Matlab/Cuda)
196
208
197
-
198
209
## Contributions and code of conduct
199
210
200
211
Every contribution is welcome and should respect the [contribution guidelines](.github/CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](.github/CODE_OF_CONDUCT.md).
0 commit comments