From d6ef8676cc3f94ba5d80acc9fd9745c9ed91819a Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 8 Apr 2020 10:28:57 +0200 Subject: remove jcpot from laplace --- examples/plot_otda_jcpot.py | 171 ----------------------------------------- ot/bregman.py | 160 --------------------------------------- ot/da.py | 181 +------------------------------------------- test/test_da.py | 56 +------------- 4 files changed, 3 insertions(+), 565 deletions(-) delete mode 100644 examples/plot_otda_jcpot.py diff --git a/examples/plot_otda_jcpot.py b/examples/plot_otda_jcpot.py deleted file mode 100644 index 316fa8b..0000000 --- a/examples/plot_otda_jcpot.py +++ /dev/null @@ -1,171 +0,0 @@ -# -*- coding: utf-8 -*- -""" -======================== -OT for multi-source target shift -======================== - -This example introduces a target shift problem with two 2D source and 1 target domain. - -""" - -# Authors: Remi Flamary -# Ievgen Redko -# -# License: MIT License - -import pylab as pl -import numpy as np -import ot -from ot.datasets import make_data_classif - -############################################################################## -# Generate data -# ------------- -n = 50 -sigma = 0.3 -np.random.seed(1985) - -p1 = .2 -dec1 = [0, 2] - -p2 = .9 -dec2 = [0, -2] - -pt = .4 -dect = [4, 0] - -xs1, ys1 = make_data_classif('2gauss_prop', n, nz=sigma, p=p1, bias=dec1) -xs2, ys2 = make_data_classif('2gauss_prop', n + 1, nz=sigma, p=p2, bias=dec2) -xt, yt = make_data_classif('2gauss_prop', n, nz=sigma, p=pt, bias=dect) - -all_Xr = [xs1, xs2] -all_Yr = [ys1, ys2] -# %% - -da = 1.5 - - -def plot_ax(dec, name): - pl.plot([dec[0], dec[0]], [dec[1] - da, dec[1] + da], 'k', alpha=0.5) - pl.plot([dec[0] - da, dec[0] + da], [dec[1], dec[1]], 'k', alpha=0.5) - pl.text(dec[0] - .5, dec[1] + 2, name) - - -############################################################################## -# Fig 1 : plots source and target samples -# --------------------------------------- - -pl.figure(1) -pl.clf() -plot_ax(dec1, 'Source 1') -plot_ax(dec2, 'Source 2') -plot_ax(dect, 'Target') -pl.scatter(xs1[:, 0], xs1[:, 1], c=ys1, s=35, marker='x', cmap='Set1', vmax=9, - label='Source 1 ({:1.2f}, {:1.2f})'.format(1 - p1, p1)) -pl.scatter(xs2[:, 0], xs2[:, 1], c=ys2, s=35, marker='+', cmap='Set1', vmax=9, - label='Source 2 ({:1.2f}, {:1.2f})'.format(1 - p2, p2)) -pl.scatter(xt[:, 0], xt[:, 1], c=yt, s=35, marker='o', cmap='Set1', vmax=9, - label='Target ({:1.2f}, {:1.2f})'.format(1 - pt, pt)) -pl.title('Data') - -pl.legend() -pl.axis('equal') -pl.axis('off') - -############################################################################## -# Instantiate Sinkhorn transport algorithm and fit them for all source domains -# ---------------------------------------------------------------------------- -ot_sinkhorn = ot.da.SinkhornTransport(reg_e=1e-1, metric='sqeuclidean') - - -def print_G(G, xs, ys, xt): - for i in range(G.shape[0]): - for j in range(G.shape[1]): - if G[i, j] > 5e-4: - if ys[i]: - c = 'b' - else: - c = 'r' - pl.plot([xs[i, 0], xt[j, 0]], [xs[i, 1], xt[j, 1]], c, alpha=.2) - - -############################################################################## -# Fig 2 : plot optimal couplings and transported samples -# ------------------------------------------------------ -pl.figure(2) -pl.clf() -plot_ax(dec1, 'Source 1') -plot_ax(dec2, 'Source 2') -plot_ax(dect, 'Target') -print_G(ot_sinkhorn.fit(Xs=xs1, Xt=xt).coupling_, xs1, ys1, xt) -print_G(ot_sinkhorn.fit(Xs=xs2, Xt=xt).coupling_, xs2, ys2, xt) -pl.scatter(xs1[:, 0], xs1[:, 1], c=ys1, s=35, marker='x', cmap='Set1', vmax=9) -pl.scatter(xs2[:, 0], xs2[:, 1], c=ys2, s=35, marker='+', cmap='Set1', vmax=9) -pl.scatter(xt[:, 0], xt[:, 1], c=yt, s=35, marker='o', cmap='Set1', vmax=9) - -pl.plot([], [], 'r', alpha=.2, label='Mass from Class 1') -pl.plot([], [], 'b', alpha=.2, label='Mass from Class 2') - -pl.title('Independent OT') - -pl.legend() -pl.axis('equal') -pl.axis('off') - -############################################################################## -# Instantiate JCPOT adaptation algorithm and fit it -# ---------------------------------------------------------------------------- -otda = ot.da.JCPOTTransport(reg_e=1e-2, max_iter=1000, metric='sqeuclidean', tol=1e-9, verbose=True, log=True) -otda.fit(all_Xr, all_Yr, xt) - -ws1 = otda.proportions_.dot(otda.log_['D2'][0]) -ws2 = otda.proportions_.dot(otda.log_['D2'][1]) - -pl.figure(3) -pl.clf() -plot_ax(dec1, 'Source 1') -plot_ax(dec2, 'Source 2') -plot_ax(dect, 'Target') -print_G(ot.bregman.sinkhorn(ws1, [], otda.log_['M'][0], reg=1e-2), xs1, ys1, xt) -print_G(ot.bregman.sinkhorn(ws2, [], otda.log_['M'][1], reg=1e-2), xs2, ys2, xt) -pl.scatter(xs1[:, 0], xs1[:, 1], c=ys1, s=35, marker='x', cmap='Set1', vmax=9) -pl.scatter(xs2[:, 0], xs2[:, 1], c=ys2, s=35, marker='+', cmap='Set1', vmax=9) -pl.scatter(xt[:, 0], xt[:, 1], c=yt, s=35, marker='o', cmap='Set1', vmax=9) - -pl.plot([], [], 'r', alpha=.2, label='Mass from Class 1') -pl.plot([], [], 'b', alpha=.2, label='Mass from Class 2') - -pl.title('OT with prop estimation ({:1.3f},{:1.3f})'.format(otda.proportions_[0], otda.proportions_[1])) - -pl.legend() -pl.axis('equal') -pl.axis('off') - -############################################################################## -# Run oracle transport algorithm with known proportions -# ---------------------------------------------------------------------------- -h_res = np.array([1 - pt, pt]) - -ws1 = h_res.dot(otda.log_['D2'][0]) -ws2 = h_res.dot(otda.log_['D2'][1]) - -pl.figure(4) -pl.clf() -plot_ax(dec1, 'Source 1') -plot_ax(dec2, 'Source 2') -plot_ax(dect, 'Target') -print_G(ot.bregman.sinkhorn(ws1, [], otda.log_['M'][0], reg=1e-2), xs1, ys1, xt) -print_G(ot.bregman.sinkhorn(ws2, [], otda.log_['M'][1], reg=1e-2), xs2, ys2, xt) -pl.scatter(xs1[:, 0], xs1[:, 1], c=ys1, s=35, marker='x', cmap='Set1', vmax=9) -pl.scatter(xs2[:, 0], xs2[:, 1], c=ys2, s=35, marker='+', cmap='Set1', vmax=9) -pl.scatter(xt[:, 0], xt[:, 1], c=yt, s=35, marker='o', cmap='Set1', vmax=9) - -pl.plot([], [], 'r', alpha=.2, label='Mass from Class 1') -pl.plot([], [], 'b', alpha=.2, label='Mass from Class 2') - -pl.title('OT with known proportion ({:1.1f},{:1.1f})'.format(h_res[0], h_res[1])) - -pl.legend() -pl.axis('equal') -pl.axis('off') -pl.show() diff --git a/ot/bregman.py b/ot/bregman.py index 61dfa52..f737e81 100644 --- a/ot/bregman.py +++ b/ot/bregman.py @@ -1503,166 +1503,6 @@ def unmix(a, D, M, M0, h0, reg, reg0, alpha, numItermax=1000, return np.sum(K0, axis=1) -def jcpot_barycenter(Xs, Ys, Xt, reg, metric='sqeuclidean', numItermax=100, - stopThr=1e-6, verbose=False, log=False, **kwargs): - r'''Joint OT and proportion estimation for multi-source target shift as proposed in [27] - - The function solves the following optimization problem: - - .. math:: - - \mathbf{h} = arg\min_{\mathbf{h}}\quad \sum_{k=1}^{K} \lambda_k - W_{reg}((\mathbf{D}_2^{(k)} \mathbf{h})^T, \mathbf{a}) - - s.t. \ \forall k, \mathbf{D}_1^{(k)} \gamma_k \mathbf{1}_n= \mathbf{h} - - where : - - - :math:`\lambda_k` is the weight of k-th source domain - - :math:`W_{reg}(\cdot,\cdot)` is the entropic regularized Wasserstein distance (see ot.bregman.sinkhorn) - - :math:`\mathbf{D}_2^{(k)}` is a matrix of weights related to k-th source domain defined as in [p. 5, 27], its expected shape is `(n_k, C)` where `n_k` is the number of elements in the k-th source domain and `C` is the number of classes - - :math:`\mathbf{h}` is a vector of estimated proportions in the target domain of size C - - :math:`\mathbf{a}` is a uniform vector of weights in the target domain of size `n` - - :math:`\mathbf{D}_1^{(k)}` is a matrix of class assignments defined as in [p. 5, 27], its expected shape is `(n_k, C)` - - The problem consist in solving a Wasserstein barycenter problem to estimate the proportions :math:`\mathbf{h}` in the target domain. - - The algorithm used for solving the problem is the Iterative Bregman projections algorithm - with two sets of marginal constraints related to the unknown vector :math:`\mathbf{h}` and uniform tarhet distribution. - - Parameters - ---------- - Xs : list of K np.ndarray(nsk,d) - features of all source domains' samples - Ys : list of K np.ndarray(nsk,) - labels of all source domains' samples - Xt : np.ndarray (nt,d) - samples in the target domain - reg : float - Regularization term > 0 - metric : string, optional (default="sqeuclidean") - The ground metric for the Wasserstein problem - numItermax : int, optional - Max number of iterations - stopThr : float, optional - Stop threshold on relative change in the barycenter (>0) - log : bool, optional - record log if True - verbose : bool, optional (default=False) - Controls the verbosity of the optimization algorithm - - Returns - ------- - gamma : List of K (nsk x nt) ndarrays - Optimal transportation matrices for the given parameters for each pair of source and target domains - h : (C,) ndarray - proportion estimation in the target domain - log : dict - log dictionary return only if log==True in parameters - - - References - ---------- - - .. [27] Ievgen Redko, Nicolas Courty, Rémi Flamary, Devis Tuia - "Optimal transport for multi-source domain adaptation under target shift", - International Conference on Artificial Intelligence and Statistics (AISTATS), 2019. - - ''' - nbclasses = len(np.unique(Ys[0])) - nbdomains = len(Xs) - - # log dictionary - if log: - log = {'niter': 0, 'err': [], 'M': [], 'D1': [], 'D2': []} - - K = [] - M = [] - D1 = [] - D2 = [] - - # For each source domain, build cost matrices M, Gibbs kernels K and corresponding matrices D_1 and D_2 - for d in range(nbdomains): - dom = {} - nsk = Xs[d].shape[0] # get number of elements for this domain - dom['nbelem'] = nsk - classes = np.unique(Ys[d]) # get number of classes for this domain - - # format classes to start from 0 for convenience - if np.min(classes) != 0: - Ys[d] = Ys[d] - np.min(classes) - classes = np.unique(Ys[d]) - - # build the corresponding D_1 and D_2 matrices - Dtmp1 = np.zeros((nbclasses, nsk)) - Dtmp2 = np.zeros((nbclasses, nsk)) - - for c in classes: - nbelemperclass = np.sum(Ys[d] == c) - if nbelemperclass != 0: - Dtmp1[int(c), Ys[d] == c] = 1. - Dtmp2[int(c), Ys[d] == c] = 1. / (nbelemperclass) - D1.append(Dtmp1) - D2.append(Dtmp2) - - # build the cost matrix and the Gibbs kernel - Mtmp = dist(Xs[d], Xt, metric=metric) - Mtmp = Mtmp / np.median(Mtmp) - M.append(Mtmp) - - Ktmp = np.empty(Mtmp.shape, dtype=Mtmp.dtype) - np.divide(Mtmp, -reg, out=Ktmp) - np.exp(Ktmp, out=Ktmp) - K.append(Ktmp) - - # uniform target distribution - a = unif(np.shape(Xt)[0]) - - cpt = 0 # iterations count - err = 1 - old_bary = np.ones((nbclasses)) - - while (err > stopThr and cpt < numItermax): - - bary = np.zeros((nbclasses)) - - # update coupling matrices for marginal constraints w.r.t. uniform target distribution - for d in range(nbdomains): - K[d] = projC(K[d], a) - other = np.sum(K[d], axis=1) - bary = bary + np.log(np.dot(D1[d], other)) / nbdomains - - bary = np.exp(bary) - - # update coupling matrices for marginal constraints w.r.t. unknown proportions based on [Prop 4., 27] - for d in range(nbdomains): - new = np.dot(D2[d].T, bary) - K[d] = projR(K[d], new) - - err = np.linalg.norm(bary - old_bary) - cpt = cpt + 1 - old_bary = bary - - if log: - log['err'].append(err) - - if verbose: - if cpt % 200 == 0: - print('{:5s}|{:12s}'.format('It.', 'Err') + '\n' + '-' * 19) - print('{:5d}|{:8e}|'.format(cpt, err)) - - bary = bary / np.sum(bary) - - if log: - log['niter'] = cpt - log['M'] = M - log['D1'] = D1 - log['D2'] = D2 - return K, bary, log - else: - return K, bary - - def empirical_sinkhorn(X_s, X_t, reg, a=None, b=None, metric='sqeuclidean', numIterMax=10000, stopThr=1e-9, verbose=False, log=False, **kwargs): diff --git a/ot/da.py b/ot/da.py index 0fdd3be..474c944 100644 --- a/ot/da.py +++ b/ot/da.py @@ -14,7 +14,7 @@ Domain adaptation with optimal transport import numpy as np import scipy.linalg as linalg -from .bregman import sinkhorn, jcpot_barycenter +from .bregman import sinkhorn from .lp import emd from .utils import unif, dist, kernel, cost_normalization, laplacian from .utils import check_params, BaseEstimator @@ -2121,181 +2121,4 @@ class UnbalancedSinkhornTransport(BaseTransport): self.coupling_ = returned_ self.log_ = dict() - return self - - -class JCPOTTransport(BaseTransport): - - """Domain Adapatation OT method for multi-source target shift based on Wasserstein barycenter algorithm. - - Parameters - ---------- - reg_e : float, optional (default=1) - Entropic regularization parameter - max_iter : int, float, optional (default=10) - The minimum number of iteration before stopping the optimization - algorithm if no it has not converged - tol : float, optional (default=10e-9) - Stop threshold on error (inner sinkhorn solver) (>0) - verbose : bool, optional (default=False) - Controls the verbosity of the optimization algorithm - log : bool, optional (default=False) - Controls the logs of the optimization algorithm - metric : string, optional (default="sqeuclidean") - The ground metric for the Wasserstein problem - norm : string, optional (default=None) - If given, normalize the ground metric to avoid numerical errors that - can occur with large metric values. - distribution_estimation : callable, optional (defaults to the uniform) - The kind of distribution estimation to employ - out_of_sample_map : string, optional (default="ferradans") - The kind of out of sample mapping to apply to transport samples - from a domain into another one. Currently the only possible option is - "ferradans" which uses the method proposed in [6]. - - Attributes - ---------- - coupling_ : list of array-like objects, shape K x (n_source_samples, n_target_samples) - A set of optimal couplings between each source domain and the target domain - proportions_ : array-like, shape (n_classes,) - Estimated class proportions in the target domain - log_ : dictionary - The dictionary of log, empty dic if parameter log is not True - - References - ---------- - - .. [1] Ievgen Redko, Nicolas Courty, Rémi Flamary, Devis Tuia - "Optimal transport for multi-source domain adaptation under target shift", - International Conference on Artificial Intelligence and Statistics (AISTATS), - vol. 89, p.849-858, 2019. - - """ - - def __init__(self, reg_e=.1, max_iter=10, - tol=10e-9, verbose=False, log=False, - metric="sqeuclidean", - out_of_sample_map='ferradans'): - self.reg_e = reg_e - self.max_iter = max_iter - self.tol = tol - self.verbose = verbose - self.log = log - self.metric = metric - self.out_of_sample_map = out_of_sample_map - - def fit(self, Xs, ys=None, Xt=None, yt=None): - """Building coupling matrices from a list of source and target sets of samples - (Xs, ys) and (Xt, yt) - - Parameters - ---------- - Xs : list of K array-like objects, shape K x (nk_source_samples, n_features) - A list of the training input samples. - ys : list of K array-like objects, shape K x (nk_source_samples,) - A list of the class labels - Xt : array-like, shape (n_target_samples, n_features) - The training input samples. - yt : array-like, shape (n_target_samples,) - The class labels. If some target samples are unlabeled, fill the - yt's elements with -1. - - Warning: Note that, due to this convention -1 cannot be used as a - class label - - Returns - ------- - self : object - Returns self. - """ - - # check the necessary inputs parameters are here - if check_params(Xs=Xs, Xt=Xt, ys=ys): - - self.xs_ = Xs - self.xt_ = Xt - - returned_ = jcpot_barycenter(Xs=Xs, Ys=ys, Xt=Xt, reg=self.reg_e, - metric=self.metric, distrinumItermax=self.max_iter, stopThr=self.tol, - verbose=self.verbose, log=self.log) - - # deal with the value of log - if self.log: - self.coupling_, self.proportions_, self.log_ = returned_ - else: - self.coupling_, self.proportions_ = returned_ - self.log_ = dict() - - return self - - def transform(self, Xs=None, ys=None, Xt=None, yt=None, batch_size=128): - """Transports source samples Xs onto target ones Xt - - Parameters - ---------- - Xs : array-like, shape (n_source_samples, n_features) - The training input samples. - ys : array-like, shape (n_source_samples,) - The class labels - Xt : array-like, shape (n_target_samples, n_features) - The training input samples. - yt : array-like, shape (n_target_samples,) - The class labels. If some target samples are unlabeled, fill the - yt's elements with -1. - - Warning: Note that, due to this convention -1 cannot be used as a - class label - batch_size : int, optional (default=128) - The batch size for out of sample inverse transform - """ - - transp_Xs = [] - - # check the necessary inputs parameters are here - if check_params(Xs=Xs): - - if all([np.allclose(x, y) for x, y in zip(self.xs_, Xs)]): - - # perform standard barycentric mapping for each source domain - - for coupling in self.coupling_: - transp = coupling / np.sum(coupling, 1)[:, None] - - # set nans to 0 - transp[~ np.isfinite(transp)] = 0 - - # compute transported samples - transp_Xs.append(np.dot(transp, self.xt_)) - else: - - # perform out of sample mapping - indices = np.arange(Xs.shape[0]) - batch_ind = [ - indices[i:i + batch_size] - for i in range(0, len(indices), batch_size)] - - transp_Xs = [] - - for bi in batch_ind: - transp_Xs_ = [] - - # get the nearest neighbor in the sources domains - xs = np.concatenate(self.xs_, axis=0) - idx = np.argmin(dist(Xs[bi], xs), axis=1) - - # transport the source samples - for coupling in self.coupling_: - transp = coupling / np.sum( - coupling, 1)[:, None] - transp[~ np.isfinite(transp)] = 0 - transp_Xs_.append(np.dot(transp, self.xt_)) - - transp_Xs_ = np.concatenate(transp_Xs_, axis=0) - - # define the transported points - transp_Xs_ = transp_Xs_[idx, :] + Xs[bi] - xs[idx, :] - transp_Xs.append(transp_Xs_) - - transp_Xs = np.concatenate(transp_Xs, axis=0) - - return transp_Xs + return self \ No newline at end of file diff --git a/test/test_da.py b/test/test_da.py index 4eaf193..0e31f26 100644 --- a/test/test_da.py +++ b/test/test_da.py @@ -549,60 +549,6 @@ def test_linear_mapping_class(): np.testing.assert_allclose(Ct, Cst, rtol=1e-2, atol=1e-2) -def test_jcpot_transport_class(): - """test_jcpot_transport - """ - - ns1 = 150 - ns2 = 150 - nt = 200 - - Xs1, ys1 = make_data_classif('3gauss', ns1) - Xs2, ys2 = make_data_classif('3gauss', ns2) - - Xt, yt = make_data_classif('3gauss2', nt) - - Xs = [Xs1, Xs2] - ys = [ys1, ys2] - - otda = ot.da.JCPOTTransport(reg_e=0.01, max_iter=1000, tol=1e-9, verbose=True, log=True) - - # test its computed - otda.fit(Xs=Xs, ys=ys, Xt=Xt) - - assert hasattr(otda, "coupling_") - assert hasattr(otda, "proportions_") - assert hasattr(otda, "log_") - - # test dimensions of coupling - for i, xs in enumerate(Xs): - assert_equal(otda.coupling_[i].shape, ((xs.shape[0], Xt.shape[0]))) - - # test all margin constraints - mu_t = unif(nt) - - for i in range(len(Xs)): - # test margin constraints w.r.t. uniform target weights for each coupling matrix - assert_allclose( - np.sum(otda.coupling_[i], axis=0), mu_t, rtol=1e-3, atol=1e-3) - - # test margin constraints w.r.t. modified source weights for each source domain - - assert_allclose( - np.dot(otda.log_['D1'][i], np.sum(otda.coupling_[i], axis=1)), otda.proportions_, rtol=1e-3, - atol=1e-3) - - # test transform - transp_Xs = otda.transform(Xs=Xs) - [assert_equal(x.shape, y.shape) for x, y in zip(transp_Xs, Xs)] - - Xs_new, _ = make_data_classif('3gauss', ns1 + 1) - transp_Xs_new = otda.transform(Xs_new) - - # check that the oos method is working - assert_equal(transp_Xs_new.shape, Xs_new.shape) - - def test_emd_laplace_class(): """test_emd_laplace_transport """ @@ -654,4 +600,4 @@ def test_emd_laplace_class(): # test fit_transform transp_Xs = otda.fit_transform(Xs=Xs, Xt=Xt) - assert_equal(transp_Xs.shape, Xs.shape) + assert_equal(transp_Xs.shape, Xs.shape) \ No newline at end of file -- cgit v1.2.3 From 4d77cc99ae5dd2cf3521ff2f136ff783c7d1d7ef Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 8 Apr 2020 10:41:53 +0200 Subject: pep test da --- test/test_da.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_da.py b/test/test_da.py index 0e31f26..befec43 100644 --- a/test/test_da.py +++ b/test/test_da.py @@ -600,4 +600,4 @@ def test_emd_laplace_class(): # test fit_transform transp_Xs = otda.fit_transform(Xs=Xs, Xt=Xt) - assert_equal(transp_Xs.shape, Xs.shape) \ No newline at end of file + assert_equal(transp_Xs.shape, Xs.shape) -- cgit v1.2.3 From 25cad1942166d25d2d305cf93937c1d5edc91716 Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 8 Apr 2020 10:54:56 +0200 Subject: pep test da --- test/test_da.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_da.py b/test/test_da.py index befec43..0e31f26 100644 --- a/test/test_da.py +++ b/test/test_da.py @@ -600,4 +600,4 @@ def test_emd_laplace_class(): # test fit_transform transp_Xs = otda.fit_transform(Xs=Xs, Xt=Xt) - assert_equal(transp_Xs.shape, Xs.shape) + assert_equal(transp_Xs.shape, Xs.shape) \ No newline at end of file -- cgit v1.2.3 From 37412f59a94e8607fdbd5f7f29434a70ebe18688 Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 8 Apr 2020 11:05:50 +0200 Subject: remove blank line --- ot/da.py | 2 +- test/test_da.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ot/da.py b/ot/da.py index 474c944..108609f 100644 --- a/ot/da.py +++ b/ot/da.py @@ -2121,4 +2121,4 @@ class UnbalancedSinkhornTransport(BaseTransport): self.coupling_ = returned_ self.log_ = dict() - return self \ No newline at end of file + return self diff --git a/test/test_da.py b/test/test_da.py index 0e31f26..befec43 100644 --- a/test/test_da.py +++ b/test/test_da.py @@ -600,4 +600,4 @@ def test_emd_laplace_class(): # test fit_transform transp_Xs = otda.fit_transform(Xs=Xs, Xt=Xt) - assert_equal(transp_Xs.shape, Xs.shape) \ No newline at end of file + assert_equal(transp_Xs.shape, Xs.shape) -- cgit v1.2.3 From 93ef47c2d408cec7aba46815639b9bede52be92d Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 11:46:36 +0200 Subject: description example laplacian --- examples/plot_otda_laplacian.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/plot_otda_laplacian.py b/examples/plot_otda_laplacian.py index 965380c..67c8f67 100644 --- a/examples/plot_otda_laplacian.py +++ b/examples/plot_otda_laplacian.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- """ -======================== -OT for domain adaptation -======================== +====================================================== +OT with Laplacian regularization for domain adaptation +====================================================== This example introduces a domain adaptation in a 2D setting and OTDA -approache with Laplacian regularization. +approach with Laplacian regularization. """ -- cgit v1.2.3 From 77cae32e956d87cfc1f69a0ea7a28c906347070d Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 16:43:40 +0200 Subject: check conflict da --- ot/da.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ot/da.py b/ot/da.py index 108609f..272af91 100644 --- a/ot/da.py +++ b/ot/da.py @@ -16,7 +16,7 @@ import scipy.linalg as linalg from .bregman import sinkhorn from .lp import emd -from .utils import unif, dist, kernel, cost_normalization, laplacian +from .utils import unif, dist, kernel, cost_normalization, label_normalization from .utils import check_params, BaseEstimator from .unbalanced import sinkhorn_unbalanced from .optim import cg -- cgit v1.2.3 From dda4941eb9bd184aee7db8eff229edc3ea1979df Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 16:44:54 +0200 Subject: conflict readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f439405..c96731c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ It provides the following solvers: * Non regularized free support Wasserstein barycenters [20]. * Unbalanced OT with KL relaxation distance and barycenter [10, 25]. * Screening Sinkhorn Algorithm for OT [26]. -* JCPOT algorithm for multi-source target shift [27]. +* JCPOT algorithm for multi-source domain adaptation with target shift [27]. Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. @@ -259,4 +259,4 @@ You can also post bug reports and feature requests in Github issues. Make sure t [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). -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. \ No newline at end of file +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. -- cgit v1.2.3 From ef50bae5a22c6e69bcc77b8f925551208079b19e Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 16:47:01 +0200 Subject: readme --- README.md | 242 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/README.md b/README.md index c96731c..8bd833c 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,60 @@ # POT: Python Optimal Transport -[![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) -[![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) -[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/rflamary/POT) -[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) -[![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) -[![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) -[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/rflamary/POT/blob/master/LICENSE) - +import ot +[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) +[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) +[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) +[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) +[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) +[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) +[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. It provides the following solvers: -* OT Network Flow solver for the linear program/ Earth Movers Distance [1]. -* Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2], stabilized version [9][10] and greedy Sinkhorn [22] with optional GPU implementation (requires cupy). -* Sinkhorn divergence [23] and entropic regularization OT from empirical data. -* Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. -* Non regularized Wasserstein barycenters [16] with LP solver (only small scale). -* Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. -* Optimal transport for domain adaptation with group lasso regularization [5] -* Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. -* Linear OT [14] and Joint OT matrix and mapping estimation [8]. -* Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). -* Gromov-Wasserstein distances and barycenters ([13] and regularized [12]) -* 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]. -* JCPOT algorithm for multi-source domain adaptation with target shift [27]. - -Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. +* OT Network Flow solver for the linear program / Earth Movers Distance[1]. +* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). +* Sinkhorn divergence[23] and entropic regularization OT from empirical data. +* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. +* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). +* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. +* Optimal transport for domain adaptation with group lasso regularization[5] +* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. +* Linear OT[14] and Joint OT matrix and mapping estimation[8]. +* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). +* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) +* 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]. +* JCPOT algorithm for multi - source domain adaptation with target shift[27]. + +Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. #### Using and citing the toolbox If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: ``` + + @misc{flamary2017pot, -title={POT Python Optimal Transport library}, -author={Flamary, R{'e}mi and Courty, Nicolas}, -url={https://github.com/rflamary/POT}, -year={2017} -} + title = {POT Python Optimal Transport library}, + author = {Flamary, R{'e}mi and Courty, Nicolas}, + url = {https: // github.com / rflamary / POT}, + year = {2017} + } ``` ## Installation -The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: +The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: -- Numpy (>=1.11) -- Scipy (>=1.0) -- Cython (>=0.23) -- Matplotlib (>=1.5) +- Numpy ( >= 1.11) +- Scipy ( >= 1.0) +- Cython ( >= 0.23) +- Matplotlib ( >= 1.5) #### Pip installation @@ -68,35 +70,33 @@ pip install POT ``` or get the very latest version by downloading it and then running: ``` -python setup.py install --user # for user install (no root) +python setup.py install - -user # for user install (no root) ``` - #### Anaconda installation with conda-forge -If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies: +If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: ``` -conda install -c conda-forge pot +conda install - c conda - forge pot ``` #### Post installation check After a correct installation, you should be able to import the module without errors: ```python -import ot ``` Note that for easier access the module is name ot instead of pot. ### Dependencies -Some sub-modules require additional dependences which are discussed below +Some sub - modules require additional dependences which are discussed below -* **ot.dr** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: +* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: ``` pip install pymanopt autograd ``` -* **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). +* **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 need CUDA installed and a compatible GPU. @@ -107,156 +107,156 @@ obviously you need CUDA installed and a compatible GPU. * Import the toolbox ```python -import ot ``` * Compute Wasserstein distances ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -Wd=ot.emd2(a,b,M) # exact linear program -Wd_reg=ot.sinkhorn2(a,b,M,reg) # entropic regularized OT +Wd = ot.emd2(a, b, M) # exact linear program +Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT # if b is a matrix compute all distances to a and return a vector ``` * Compute OT matrix ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -T=ot.emd(a,b,M) # exact linear program -T_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT +T = ot.emd(a, b, M) # exact linear program +T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT ``` * Compute Wasserstein barycenter ```python # A is a n*d matrix containing d 1D histograms # M is the ground cost matrix -ba=ot.barycenter(A,M,reg) # reg is regularization parameter +ba = ot.barycenter(A, M, reg) # reg is regularization parameter ``` - - ### Examples and Notebooks -The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/). +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). -Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look: +Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: -* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb) -* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb) -* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb) -* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) +* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) +* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) +* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) +* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) -You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/). +You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). ## Acknowledgements This toolbox has been created and is maintained by -* [Rémi Flamary](http://remi.flamary.com/) -* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/) +* [Rémi Flamary](http: // remi.flamary.com / ) +* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) -The contributors to this library are +The contributors to this library are -* [Alexandre Gramfort](http://alexandre.gramfort.net/) -* [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/) -* [Michael Perrot](http://perso.univ-st-etienne.fr/pem82055/) (Mapping estimation) -* [Léo Gautheron](https://github.com/aje) (GPU implementation) -* [Nathalie Gayraud](https://www.linkedin.com/in/nathalie-t-h-gayraud/?ppe=1) -* [Stanislas Chambon](https://slasnista.github.io/) -* [Antoine Rolet](https://arolet.github.io/) -* Erwan Vautier (Gromov-Wasserstein) -* [Kilian Fatras](https://kilianfatras.github.io/) -* [Alain Rakotomamonjy](https://sites.google.com/site/alainrakotomamonjy/home) -* [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) +* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) +* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) +* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) +* [Léo Gautheron](https: // github.com / aje)(GPU implementation) +* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) +* [Stanislas Chambon](https: // slasnista.github.io / ) +* [Antoine Rolet](https: // arolet.github.io / ) +* Erwan Vautier(Gromov - Wasserstein) +* [Kilian Fatras](https: // kilianfatras.github.io / ) +* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) +* [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): +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): -* [Gabriel Peyré](http://gpeyre.github.io/) (Wasserstein Barycenters in Matlab) -* [Nicolas Bonneel](http://liris.cnrs.fr/~nbonneel/) ( C++ code for EMD) -* [Marco Cuturi](http://marcocuturi.net/) (Sinkhorn Knopp in Matlab/Cuda) +* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) +* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) +* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) ## Contributions and code of conduct -Every contribution is welcome and should respect the [contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md). +Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). ## Support You can ask questions and join the development discussion: -* On the [POT Slack channel](https://pot-toolbox.slack.com) -* On the POT [mailing list](https://mail.python.org/mm3/mailman3/lists/pot.python.org/) +* On the[POT Slack channel](https: // pot - toolbox.slack.com) +* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) -You can also post bug reports and feature requests in Github issues. Make sure to read our [guidelines](CONTRIBUTING.md) first. +You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. ## References -[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https://people.csail.mit.edu/sparis/publi/2011/sigasia/Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics (TOG) (Vol. 30, No. 6, p. 158). ACM. +[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. -[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https://arxiv.org/pdf/1306.0895.pdf). In Advances in Neural Information Processing Systems (pp. 2292-2300). +[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). -[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https://arxiv.org/pdf/1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111-A1138. +[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. -[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https://hal.archives-ouvertes.fr/hal-01377236/document), Whorkshop on Hyperspectral Image and Signal Processing : Evolution in Remote Sensing (WHISPERS), 2016. +[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. -[5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https://arxiv.org/pdf/1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 +[5] N. Courty +R. Flamary +D. Tuia +A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 -[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https://arxiv.org/pdf/1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853-1882. +[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. -[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https://arxiv.org/pdf/1510.06567.pdf). arXiv preprint arXiv:1510.06567. +[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. -[8] M. Perrot, N. Courty, R. Flamary, A. Habrard (2016), [Mapping estimation for discrete optimal transport](http://remi.flamary.com/biblio/perrot2016mapping.pdf), Neural Information Processing Systems (NIPS). +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). -[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https://arxiv.org/pdf/1610.06519.pdf). arXiv preprint arXiv:1610.06519. +[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. -[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https://arxiv.org/pdf/1607.05816.pdf). arXiv preprint arXiv:1607.05816. +[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. -[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https://arxiv.org/pdf/1608.08063.pdf). arXiv preprint arXiv:1608.08063. +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. -[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon (2016), [Gromov-Wasserstein averaging of kernel and distance matrices](http://proceedings.mlr.press/v48/peyre16.html) International Conference on Machine Learning (ICML). +[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). -[13] Mémoli, Facundo (2011). [Gromov–Wasserstein distances and the metric approach to object matching](https://media.adelaide.edu.au/acvt/Publications/2011/2011-Gromov%E2%80%93Wasserstein%20Distances%20and%20the%20Metric%20Approach%20to%20Object%20Matching.pdf). Foundations of computational mathematics 11.4 : 417-487. +[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. -[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https://link.springer.com/article/10.1007/BF00934745), Journal of Optimization Theory and Applications Vol 43. +[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. -[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https://arxiv.org/pdf/1803.00567.pdf) . +[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . -[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https://hal.archives-ouvertes.fr/hal-00637399/document). SIAM Journal on Mathematical Analysis, 43(2), 904-924. +[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. -[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https://arxiv.org/abs/1710.06276). Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics (AISTATS). +[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). -[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016) [Stochastic Optimization for Large-scale Optimal Transport](https://arxiv.org/abs/1605.08527). Advances in Neural Information Processing Systems (2016). +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). -[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A.& Blondel, M. [Large-scale Optimal Transport and Mapping Estimation](https://arxiv.org/pdf/1711.02283.pdf). International Conference on Learning Representation (2018) +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) -[20] Cuturi, M. and Doucet, A. (2014) [Fast Computation of Wasserstein Barycenters](http://proceedings.mlr.press/v32/cuturi14.html). International Conference in Machine Learning +[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning -[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https://dl.acm.org/citation.cfm?id=2766963). ACM Transactions on Graphics (TOG), 34(4), 66. +[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. -[22] J. Altschuler, J.Weed, P. Rigollet, (2017) [Near-linear time approximation algorithms for optimal transport via Sinkhorn iteration](https://papers.nips.cc/paper/6792-near-linear-time-approximation-algorithms-for-optimal-transport-via-sinkhorn-iteration.pdf), Advances in Neural Information Processing Systems (NIPS) 31 +[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 -[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https://arxiv.org/abs/1706.00292), Proceedings of the Twenty-First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 +[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 -[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). +[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. (2015). [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). +[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). [27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. -- cgit v1.2.3 From 33ba700a97a5f76ef0845bb2187fc3d8c594191a Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 16:47:48 +0200 Subject: readme conflict --- README.md | 242 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/README.md b/README.md index 8bd833c..c96731c 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,58 @@ # POT: Python Optimal Transport -import ot -[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) -[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) -[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) -[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) -[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) -[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) -[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) +[![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) +[![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) +[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/rflamary/POT) +[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) +[![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) +[![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) +[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/rflamary/POT/blob/master/LICENSE) + This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. It provides the following solvers: -* OT Network Flow solver for the linear program / Earth Movers Distance[1]. -* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). -* Sinkhorn divergence[23] and entropic regularization OT from empirical data. -* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. -* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). -* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. -* Optimal transport for domain adaptation with group lasso regularization[5] -* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. -* Linear OT[14] and Joint OT matrix and mapping estimation[8]. -* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). -* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) -* 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]. -* JCPOT algorithm for multi - source domain adaptation with target shift[27]. - -Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. +* OT Network Flow solver for the linear program/ Earth Movers Distance [1]. +* Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2], stabilized version [9][10] and greedy Sinkhorn [22] with optional GPU implementation (requires cupy). +* Sinkhorn divergence [23] and entropic regularization OT from empirical data. +* Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. +* Non regularized Wasserstein barycenters [16] with LP solver (only small scale). +* Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. +* Optimal transport for domain adaptation with group lasso regularization [5] +* Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. +* Linear OT [14] and Joint OT matrix and mapping estimation [8]. +* Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). +* Gromov-Wasserstein distances and barycenters ([13] and regularized [12]) +* 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]. +* JCPOT algorithm for multi-source domain adaptation with target shift [27]. + +Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. #### Using and citing the toolbox If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: ``` - - @misc{flamary2017pot, - title = {POT Python Optimal Transport library}, - author = {Flamary, R{'e}mi and Courty, Nicolas}, - url = {https: // github.com / rflamary / POT}, - year = {2017} - } +title={POT Python Optimal Transport library}, +author={Flamary, R{'e}mi and Courty, Nicolas}, +url={https://github.com/rflamary/POT}, +year={2017} +} ``` ## Installation -The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: +The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: -- Numpy ( >= 1.11) -- Scipy ( >= 1.0) -- Cython ( >= 0.23) -- Matplotlib ( >= 1.5) +- Numpy (>=1.11) +- Scipy (>=1.0) +- Cython (>=0.23) +- Matplotlib (>=1.5) #### Pip installation @@ -70,33 +68,35 @@ pip install POT ``` or get the very latest version by downloading it and then running: ``` -python setup.py install - -user # for user install (no root) +python setup.py install --user # for user install (no root) ``` + #### Anaconda installation with conda-forge -If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: +If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies: ``` -conda install - c conda - forge pot +conda install -c conda-forge pot ``` #### Post installation check After a correct installation, you should be able to import the module without errors: ```python +import ot ``` Note that for easier access the module is name ot instead of pot. ### Dependencies -Some sub - modules require additional dependences which are discussed below +Some sub-modules require additional dependences which are discussed below -* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: +* **ot.dr** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: ``` pip install pymanopt autograd ``` -* **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). +* **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 need CUDA installed and a compatible GPU. @@ -107,156 +107,156 @@ obviously you need CUDA installed and a compatible GPU. * Import the toolbox ```python +import ot ``` * Compute Wasserstein distances ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -Wd = ot.emd2(a, b, M) # exact linear program -Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT +Wd=ot.emd2(a,b,M) # exact linear program +Wd_reg=ot.sinkhorn2(a,b,M,reg) # entropic regularized OT # if b is a matrix compute all distances to a and return a vector ``` * Compute OT matrix ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -T = ot.emd(a, b, M) # exact linear program -T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT +T=ot.emd(a,b,M) # exact linear program +T_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT ``` * Compute Wasserstein barycenter ```python # A is a n*d matrix containing d 1D histograms # M is the ground cost matrix -ba = ot.barycenter(A, M, reg) # reg is regularization parameter +ba=ot.barycenter(A,M,reg) # reg is regularization parameter ``` + + ### Examples and Notebooks -The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/). -Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: +Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look: -* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) -* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) -* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) -* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) +* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb) +* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb) +* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb) +* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) -You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). +You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/). ## Acknowledgements This toolbox has been created and is maintained by -* [Rémi Flamary](http: // remi.flamary.com / ) -* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) +* [Rémi Flamary](http://remi.flamary.com/) +* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/) -The contributors to this library are +The contributors to this library are -* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) -* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) -* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) -* [Léo Gautheron](https: // github.com / aje)(GPU implementation) -* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) -* [Stanislas Chambon](https: // slasnista.github.io / ) -* [Antoine Rolet](https: // arolet.github.io / ) -* Erwan Vautier(Gromov - Wasserstein) -* [Kilian Fatras](https: // kilianfatras.github.io / ) -* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) -* [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) +* [Alexandre Gramfort](http://alexandre.gramfort.net/) +* [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/) +* [Michael Perrot](http://perso.univ-st-etienne.fr/pem82055/) (Mapping estimation) +* [Léo Gautheron](https://github.com/aje) (GPU implementation) +* [Nathalie Gayraud](https://www.linkedin.com/in/nathalie-t-h-gayraud/?ppe=1) +* [Stanislas Chambon](https://slasnista.github.io/) +* [Antoine Rolet](https://arolet.github.io/) +* Erwan Vautier (Gromov-Wasserstein) +* [Kilian Fatras](https://kilianfatras.github.io/) +* [Alain Rakotomamonjy](https://sites.google.com/site/alainrakotomamonjy/home) +* [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): +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): -* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) -* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) -* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) +* [Gabriel Peyré](http://gpeyre.github.io/) (Wasserstein Barycenters in Matlab) +* [Nicolas Bonneel](http://liris.cnrs.fr/~nbonneel/) ( C++ code for EMD) +* [Marco Cuturi](http://marcocuturi.net/) (Sinkhorn Knopp in Matlab/Cuda) ## Contributions and code of conduct -Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). +Every contribution is welcome and should respect the [contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md). ## Support You can ask questions and join the development discussion: -* On the[POT Slack channel](https: // pot - toolbox.slack.com) -* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) +* On the [POT Slack channel](https://pot-toolbox.slack.com) +* On the POT [mailing list](https://mail.python.org/mm3/mailman3/lists/pot.python.org/) -You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. +You can also post bug reports and feature requests in Github issues. Make sure to read our [guidelines](CONTRIBUTING.md) first. ## References -[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. +[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https://people.csail.mit.edu/sparis/publi/2011/sigasia/Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics (TOG) (Vol. 30, No. 6, p. 158). ACM. -[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). +[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https://arxiv.org/pdf/1306.0895.pdf). In Advances in Neural Information Processing Systems (pp. 2292-2300). -[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. +[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https://arxiv.org/pdf/1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111-A1138. -[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. +[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https://hal.archives-ouvertes.fr/hal-01377236/document), Whorkshop on Hyperspectral Image and Signal Processing : Evolution in Remote Sensing (WHISPERS), 2016. -[5] N. Courty -R. Flamary -D. Tuia -A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 +[5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https://arxiv.org/pdf/1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 -[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. +[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https://arxiv.org/pdf/1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853-1882. -[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. +[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https://arxiv.org/pdf/1510.06567.pdf). arXiv preprint arXiv:1510.06567. -[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard (2016), [Mapping estimation for discrete optimal transport](http://remi.flamary.com/biblio/perrot2016mapping.pdf), Neural Information Processing Systems (NIPS). -[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. +[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https://arxiv.org/pdf/1610.06519.pdf). arXiv preprint arXiv:1610.06519. -[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. +[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https://arxiv.org/pdf/1607.05816.pdf). arXiv preprint arXiv:1607.05816. -[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https://arxiv.org/pdf/1608.08063.pdf). arXiv preprint arXiv:1608.08063. -[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). +[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon (2016), [Gromov-Wasserstein averaging of kernel and distance matrices](http://proceedings.mlr.press/v48/peyre16.html) International Conference on Machine Learning (ICML). -[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. +[13] Mémoli, Facundo (2011). [Gromov–Wasserstein distances and the metric approach to object matching](https://media.adelaide.edu.au/acvt/Publications/2011/2011-Gromov%E2%80%93Wasserstein%20Distances%20and%20the%20Metric%20Approach%20to%20Object%20Matching.pdf). Foundations of computational mathematics 11.4 : 417-487. -[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. +[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https://link.springer.com/article/10.1007/BF00934745), Journal of Optimization Theory and Applications Vol 43. -[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . +[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https://arxiv.org/pdf/1803.00567.pdf) . -[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. +[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https://hal.archives-ouvertes.fr/hal-00637399/document). SIAM Journal on Mathematical Analysis, 43(2), 904-924. -[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). +[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https://arxiv.org/abs/1710.06276). Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics (AISTATS). -[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016) [Stochastic Optimization for Large-scale Optimal Transport](https://arxiv.org/abs/1605.08527). Advances in Neural Information Processing Systems (2016). -[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A.& Blondel, M. [Large-scale Optimal Transport and Mapping Estimation](https://arxiv.org/pdf/1711.02283.pdf). International Conference on Learning Representation (2018) -[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning +[20] Cuturi, M. and Doucet, A. (2014) [Fast Computation of Wasserstein Barycenters](http://proceedings.mlr.press/v32/cuturi14.html). International Conference in Machine Learning -[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. +[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https://dl.acm.org/citation.cfm?id=2766963). ACM Transactions on Graphics (TOG), 34(4), 66. -[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 +[22] J. Altschuler, J.Weed, P. Rigollet, (2017) [Near-linear time approximation algorithms for optimal transport via Sinkhorn iteration](https://papers.nips.cc/paper/6792-near-linear-time-approximation-algorithms-for-optimal-transport-via-sinkhorn-iteration.pdf), Advances in Neural Information Processing Systems (NIPS) 31 -[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 +[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https://arxiv.org/abs/1706.00292), Proceedings of the Twenty-First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 -[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). +[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. (2015). [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). +[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). [27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. -- cgit v1.2.3 From 7b98abfe9769475afe3b34e2ac4c7f0275fa0e6f Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 16:50:17 +0200 Subject: conflict readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c96731c..b6baf14 100644 --- a/README.md +++ b/README.md @@ -259,4 +259,4 @@ You can also post bug reports and feature requests in Github issues. Make sure t [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). -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. \ No newline at end of file -- cgit v1.2.3 From 2571a3ead11a7fc010ed20b1af6faeef464565a1 Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 17:00:32 +0200 Subject: conflict test_da --- test/test_da.py | 132 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 110 insertions(+), 22 deletions(-) diff --git a/test/test_da.py b/test/test_da.py index befec43..7d0fdda 100644 --- a/test/test_da.py +++ b/test/test_da.py @@ -65,6 +65,16 @@ def test_sinkhorn_lpl1_transport_class(): transp_Xs = otda.fit_transform(Xs=Xs, ys=ys, Xt=Xt) assert_equal(transp_Xs.shape, Xs.shape) + # check label propagation + transp_yt = otda.transform_labels(ys) + assert_equal(transp_yt.shape[0], yt.shape[0]) + assert_equal(transp_yt.shape[1], len(np.unique(ys))) + + # check inverse label propagation + transp_ys = otda.inverse_transform_labels(yt) + assert_equal(transp_ys.shape[0], ys.shape[0]) + assert_equal(transp_ys.shape[1], len(np.unique(yt))) + # test unsupervised vs semi-supervised mode otda_unsup = ot.da.SinkhornLpl1Transport() otda_unsup.fit(Xs=Xs, ys=ys, Xt=Xt) @@ -129,6 +139,16 @@ def test_sinkhorn_l1l2_transport_class(): transp_Xt = otda.inverse_transform(Xt=Xt) assert_equal(transp_Xt.shape, Xt.shape) + # check label propagation + transp_yt = otda.transform_labels(ys) + assert_equal(transp_yt.shape[0], yt.shape[0]) + assert_equal(transp_yt.shape[1], len(np.unique(ys))) + + # check inverse label propagation + transp_ys = otda.inverse_transform_labels(yt) + assert_equal(transp_ys.shape[0], ys.shape[0]) + assert_equal(transp_ys.shape[1], len(np.unique(yt))) + Xt_new, _ = make_data_classif('3gauss2', nt + 1) transp_Xt_new = otda.inverse_transform(Xt=Xt_new) @@ -210,6 +230,16 @@ def test_sinkhorn_transport_class(): transp_Xt = otda.inverse_transform(Xt=Xt) assert_equal(transp_Xt.shape, Xt.shape) + # check label propagation + transp_yt = otda.transform_labels(ys) + assert_equal(transp_yt.shape[0], yt.shape[0]) + assert_equal(transp_yt.shape[1], len(np.unique(ys))) + + # check inverse label propagation + transp_ys = otda.inverse_transform_labels(yt) + assert_equal(transp_ys.shape[0], ys.shape[0]) + assert_equal(transp_ys.shape[1], len(np.unique(yt))) + Xt_new, _ = make_data_classif('3gauss2', nt + 1) transp_Xt_new = otda.inverse_transform(Xt=Xt_new) @@ -271,6 +301,16 @@ def test_unbalanced_sinkhorn_transport_class(): transp_Xs = otda.transform(Xs=Xs) assert_equal(transp_Xs.shape, Xs.shape) + # check label propagation + transp_yt = otda.transform_labels(ys) + assert_equal(transp_yt.shape[0], yt.shape[0]) + assert_equal(transp_yt.shape[1], len(np.unique(ys))) + + # check inverse label propagation + transp_ys = otda.inverse_transform_labels(yt) + assert_equal(transp_ys.shape[0], ys.shape[0]) + assert_equal(transp_ys.shape[1], len(np.unique(yt))) + Xs_new, _ = make_data_classif('3gauss', ns + 1) transp_Xs_new = otda.transform(Xs_new) @@ -353,6 +393,16 @@ def test_emd_transport_class(): transp_Xt = otda.inverse_transform(Xt=Xt) assert_equal(transp_Xt.shape, Xt.shape) + # check label propagation + transp_yt = otda.transform_labels(ys) + assert_equal(transp_yt.shape[0], yt.shape[0]) + assert_equal(transp_yt.shape[1], len(np.unique(ys))) + + # check inverse label propagation + transp_ys = otda.inverse_transform_labels(yt) + assert_equal(transp_ys.shape[0], ys.shape[0]) + assert_equal(transp_ys.shape[1], len(np.unique(yt))) + Xt_new, _ = make_data_classif('3gauss2', nt + 1) transp_Xt_new = otda.inverse_transform(Xt=Xt_new) @@ -549,55 +599,93 @@ def test_linear_mapping_class(): np.testing.assert_allclose(Ct, Cst, rtol=1e-2, atol=1e-2) -def test_emd_laplace_class(): - """test_emd_laplace_transport +def test_jcpot_transport_class(): + """test_jcpot_transport """ - ns = 150 + + ns1 = 150 + ns2 = 150 nt = 200 - Xs, ys = make_data_classif('3gauss', ns) + Xs1, ys1 = make_data_classif('3gauss', ns1) + Xs2, ys2 = make_data_classif('3gauss', ns2) + Xt, yt = make_data_classif('3gauss2', nt) - otda = ot.da.EMDLaplaceTransport(reg_lap=0.01, max_iter=1000, tol=1e-9, verbose=False, log=True) + Xs = [Xs1, Xs2] + ys = [ys1, ys2] + + otda = ot.da.JCPOTTransport(reg_e=1, max_iter=10000, tol=1e-9, verbose=True, log=True) # test its computed otda.fit(Xs=Xs, ys=ys, Xt=Xt) assert hasattr(otda, "coupling_") + assert hasattr(otda, "proportions_") assert hasattr(otda, "log_") # test dimensions of coupling - assert_equal(otda.coupling_.shape, ((Xs.shape[0], Xt.shape[0]))) + for i, xs in enumerate(Xs): + assert_equal(otda.coupling_[i].shape, ((xs.shape[0], Xt.shape[0]))) # test all margin constraints - mu_s = unif(ns) mu_t = unif(nt) - assert_allclose( - np.sum(otda.coupling_, axis=0), mu_t, rtol=1e-3, atol=1e-3) - assert_allclose( - np.sum(otda.coupling_, axis=1), mu_s, rtol=1e-3, atol=1e-3) + for i in range(len(Xs)): + # test margin constraints w.r.t. uniform target weights for each coupling matrix + assert_allclose( + np.sum(otda.coupling_[i], axis=0), mu_t, rtol=1e-3, atol=1e-3) + + # test margin constraints w.r.t. modified source weights for each source domain + + assert_allclose( + np.dot(otda.log_['D1'][i], np.sum(otda.coupling_[i], axis=1)), otda.proportions_, rtol=1e-3, + atol=1e-3) # test transform transp_Xs = otda.transform(Xs=Xs) [assert_equal(x.shape, y.shape) for x, y in zip(transp_Xs, Xs)] - Xs_new, _ = make_data_classif('3gauss', ns + 1) + Xs_new, _ = make_data_classif('3gauss', ns1 + 1) transp_Xs_new = otda.transform(Xs_new) # check that the oos method is working assert_equal(transp_Xs_new.shape, Xs_new.shape) - # test inverse transform - transp_Xt = otda.inverse_transform(Xt=Xt) - assert_equal(transp_Xt.shape, Xt.shape) + # check label propagation + transp_yt = otda.transform_labels(ys) + assert_equal(transp_yt.shape[0], yt.shape[0]) + assert_equal(transp_yt.shape[1], len(np.unique(ys))) - Xt_new, _ = make_data_classif('3gauss2', nt + 1) - transp_Xt_new = otda.inverse_transform(Xt=Xt_new) + # check inverse label propagation + transp_ys = otda.inverse_transform_labels(yt) + [assert_equal(x.shape[0], y.shape[0]) for x, y in zip(transp_ys, ys)] + [assert_equal(x.shape[1], len(np.unique(y))) for x, y in zip(transp_ys, ys)] - # check that the oos method is working - assert_equal(transp_Xt_new.shape, Xt_new.shape) - # test fit_transform - transp_Xs = otda.fit_transform(Xs=Xs, Xt=Xt) - assert_equal(transp_Xs.shape, Xs.shape) +def test_jcpot_barycenter(): + """test_jcpot_barycenter + """ + + ns1 = 150 + ns2 = 150 + nt = 200 + + sigma = 0.1 + np.random.seed(1985) + + ps1 = .2 + ps2 = .9 + pt = .4 + + Xs1, ys1 = make_data_classif('2gauss_prop', ns1, nz=sigma, p=ps1) + Xs2, ys2 = make_data_classif('2gauss_prop', ns2, nz=sigma, p=ps2) + Xt, yt = make_data_classif('2gauss_prop', nt, nz=sigma, p=pt) + + Xs = [Xs1, Xs2] + ys = [ys1, ys2] + + prop = ot.bregman.jcpot_barycenter(Xs, ys, Xt, reg=.5, metric='sqeuclidean', + numItermax=10000, stopThr=1e-9, verbose=False, log=False) + + np.testing.assert_allclose(prop, [1 - pt, pt], rtol=1e-3, atol=1e-3) -- cgit v1.2.3 From 1c60175fee4eb7f29b49f693e91f59720369edb1 Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 17:06:02 +0200 Subject: conflict test_da --- test/test_da.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/test/test_da.py b/test/test_da.py index 7d0fdda..3b28119 100644 --- a/test/test_da.py +++ b/test/test_da.py @@ -689,3 +689,67 @@ def test_jcpot_barycenter(): numItermax=10000, stopThr=1e-9, verbose=False, log=False) np.testing.assert_allclose(prop, [1 - pt, pt], rtol=1e-3, atol=1e-3) + + +def test_emd_laplace_class(): + """test_emd_laplace_transport + """ + ns = 150 + nt = 200 + + Xs, ys = make_data_classif('3gauss', ns) + Xt, yt = make_data_classif('3gauss2', nt) + + otda = ot.da.EMDLaplaceTransport(reg_lap=0.01, max_iter=1000, tol=1e-9, verbose=False, log=True) + + # test its computed + otda.fit(Xs=Xs, ys=ys, Xt=Xt) + + assert hasattr(otda, "coupling_") + assert hasattr(otda, "log_") + + # test dimensions of coupling + assert_equal(otda.coupling_.shape, ((Xs.shape[0], Xt.shape[0]))) + + # test all margin constraints + mu_s = unif(ns) + mu_t = unif(nt) + + assert_allclose( + np.sum(otda.coupling_, axis=0), mu_t, rtol=1e-3, atol=1e-3) + assert_allclose( + np.sum(otda.coupling_, axis=1), mu_s, rtol=1e-3, atol=1e-3) + + # test transform + transp_Xs = otda.transform(Xs=Xs) + [assert_equal(x.shape, y.shape) for x, y in zip(transp_Xs, Xs)] + + Xs_new, _ = make_data_classif('3gauss', ns + 1) + transp_Xs_new = otda.transform(Xs_new) + + # check that the oos method is working + assert_equal(transp_Xs_new.shape, Xs_new.shape) + + # test inverse transform + transp_Xt = otda.inverse_transform(Xt=Xt) + assert_equal(transp_Xt.shape, Xt.shape) + + Xt_new, _ = make_data_classif('3gauss2', nt + 1) + transp_Xt_new = otda.inverse_transform(Xt=Xt_new) + + # check that the oos method is working + assert_equal(transp_Xt_new.shape, Xt_new.shape) + + # test fit_transform + transp_Xs = otda.fit_transform(Xs=Xs, Xt=Xt) + assert_equal(transp_Xs.shape, Xs.shape) + + # check label propagation + transp_yt = otda.transform_labels(ys) + assert_equal(transp_yt.shape[0], yt.shape[0]) + assert_equal(transp_yt.shape[1], len(np.unique(ys))) + + # check inverse label propagation + transp_ys = otda.inverse_transform_labels(yt) + assert_equal(transp_ys.shape[0], ys.shape[0]) + assert_equal(transp_ys.shape[1], len(np.unique(yt))) -- cgit v1.2.3 From 6c64f16acd7421ff6278119eb68877d845820fac Mon Sep 17 00:00:00 2001 From: ievred Date: Wed, 15 Apr 2020 17:13:31 +0200 Subject: import laplacian --- ot/da.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ot/da.py b/ot/da.py index ef05181..a6d7d9b 100644 --- a/ot/da.py +++ b/ot/da.py @@ -16,7 +16,7 @@ import scipy.linalg as linalg from .bregman import sinkhorn, jcpot_barycenter from .lp import emd -from .utils import unif, dist, kernel, cost_normalization, label_normalization +from .utils import unif, dist, kernel, cost_normalization, label_normalization, laplacian from .utils import check_params, BaseEstimator from .unbalanced import sinkhorn_unbalanced from .optim import cg -- cgit v1.2.3 From 14fbb88333971f575510747fd6e9217ec50d9780 Mon Sep 17 00:00:00 2001 From: ievred Date: Thu, 16 Apr 2020 16:09:22 +0200 Subject: references added --- README.md | 7 +++++-- ot/da.py | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b6baf14..304f249 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ It provides the following solvers: * Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. * Non regularized Wasserstein barycenters [16] with LP solver (only small scale). * Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. -* Optimal transport for domain adaptation with group lasso regularization [5] +* Optimal transport for domain adaptation with group lasso and Laplacian regularization [5] * Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. * Linear OT [14] and Joint OT matrix and mapping estimation [8]. * Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). @@ -183,6 +183,7 @@ The contributors to this library are * [Hicham Janati](https://hichamjanati.github.io/) (Unbalanced OT) * [Romain Tavenard](https://rtavenar.github.io/) (1d Wasserstein) * [Mokhtar Z. Alaya](http://mzalaya.github.io/) (Screenkhorn) +* [Ievgen Redko](https://ievred.github.io/) 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): @@ -259,4 +260,6 @@ You can also post bug reports and feature requests in Github issues. Make sure t [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). -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. \ No newline at end of file +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. + +[28] Flamary R., Courty N., Tuia D., Rakotomamonjy A. (2014). [Optimal transport with Laplacian regularization: Applications to domain adaptation and shape matching](https://remi.flamary.com/biblio/flamary2014optlaplace.pdf), NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. diff --git a/ot/da.py b/ot/da.py index a6d7d9b..be959d6 100644 --- a/ot/da.py +++ b/ot/da.py @@ -818,6 +818,9 @@ def emd_laplace(a, b, xs, xt, M, sim, eta, alpha, "Optimal Transport for Domain Adaptation," in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 + .. [28] R. Flamary, N. Courty, D. Tuia, A. Rakotomamonjy, + "Optimal transport with Laplacian regularization: Applications to domain adaptation and shape matching," + in NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. See Also -------- @@ -1729,6 +1732,9 @@ class EMDLaplaceTransport(BaseTransport): .. [1] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, "Optimal Transport for Domain Adaptation," in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 + .. [2] R. Flamary, N. Courty, D. Tuia, A. Rakotomamonjy, + "Optimal transport with Laplacian regularization: Applications to domain adaptation and shape matching," + in NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. """ def __init__(self, reg_lap=1., reg_src=1., alpha=0.5, -- cgit v1.2.3 From 126903381374a1d2f934190b208d134a0495dc65 Mon Sep 17 00:00:00 2001 From: ievred Date: Fri, 17 Apr 2020 16:41:14 +0200 Subject: added regulrization from [6]+fix other issues --- ot/da.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/ot/da.py b/ot/da.py index be959d6..9e00dce 100644 --- a/ot/da.py +++ b/ot/da.py @@ -16,7 +16,7 @@ import scipy.linalg as linalg from .bregman import sinkhorn, jcpot_barycenter from .lp import emd -from .utils import unif, dist, kernel, cost_normalization, label_normalization, laplacian +from .utils import unif, dist, kernel, cost_normalization, label_normalization, laplacian, dots from .utils import check_params, BaseEstimator from .unbalanced import sinkhorn_unbalanced from .optim import cg @@ -748,7 +748,7 @@ def OT_mapping_linear(xs, xt, reg=1e-6, ws=None, return A, b -def emd_laplace(a, b, xs, xt, M, sim, eta, alpha, +def emd_laplace(a, b, xs, xt, M, sim, reg, eta, alpha, numItermax, stopThr, numInnerItermax, stopInnerThr, log=False, verbose=False, **kwargs): r"""Solve the optimal transport problem (OT) with Laplacian regularization @@ -785,6 +785,8 @@ def emd_laplace(a, b, xs, xt, M, sim, eta, alpha, samples in the target domain M : np.ndarray (ns,nt) loss matrix + reg : string + Type of Laplacian regularization eta : float Regularization term for Laplacian regularization alpha : float @@ -844,6 +846,8 @@ def emd_laplace(a, b, xs, xt, M, sim, eta, alpha, sS = (sS + sS.T) / 2 sT = kneighbors_graph(xt, kwargs['nn']).toarray() sT = (sT + sT.T) / 2 + else: + raise ValueError('Unknown similarity type {sim}. Currently supported similarity types are "knn" and "gauss".'.format(sim=sim)) lS = laplacian(sS) lT = laplacian(sT) @@ -852,9 +856,18 @@ def emd_laplace(a, b, xs, xt, M, sim, eta, alpha, return alpha * np.trace(np.dot(xt.T, np.dot(G.T, np.dot(lS, np.dot(G, xt))))) \ + (1 - alpha) * np.trace(np.dot(xs.T, np.dot(G, np.dot(lT, np.dot(G.T, xs))))) + ls2 = lS + lS.T + lt2 = lT + lT.T + xt2 = np.dot(xt, xt.T) + + if reg == 'disp': + Cs = -eta * alpha / xs.shape[0] * dots(ls2, xs, xt.T) + Ct = -eta * (1 - alpha) / xt.shape[0] * dots(xs, xt.T, lt2) + M = M + Cs + Ct + def df(G): - return alpha * np.dot(lS + lS.T, np.dot(G, np.dot(xt, xt.T)))\ - + (1 - alpha) * np.dot(xs, np.dot(xs.T, np.dot(G, lT + lT.T))) + return alpha * np.dot(ls2, np.dot(G, xt2))\ + + (1 - alpha) * np.dot(xs, np.dot(xs.T, np.dot(G, lt2))) return cg(a, b, M, reg=eta, f=f, df=df, G0=None, numItermax=numItermax, numItermaxEmd=numInnerItermax, stopThr=stopThr, stopThr2=stopInnerThr, verbose=verbose, log=log) @@ -1694,6 +1707,9 @@ class EMDLaplaceTransport(BaseTransport): Parameters ---------- + reg_type : string optional (default='pos') + Type of the regularization term: 'pos' and 'disp' for + regularization term defined in [2] and [6], respectively. reg_lap : float, optional (default=1) Laplacian regularization parameter reg_src : float, optional (default=0.5) @@ -1737,11 +1753,12 @@ class EMDLaplaceTransport(BaseTransport): in NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. """ - def __init__(self, reg_lap=1., reg_src=1., alpha=0.5, + def __init__(self, reg_type='pos', reg_lap=1., reg_src=1., alpha=0.5, metric="sqeuclidean", norm=None, similarity="knn", max_iter=100, tol=1e-9, max_inner_iter=100000, inner_tol=1e-9, log=False, verbose=False, distribution_estimation=distribution_estimation_uniform, out_of_sample_map='ferradans'): + self.reg = reg_type self.reg_lap = reg_lap self.reg_src = reg_src self.alpha = alpha @@ -1785,7 +1802,7 @@ class EMDLaplaceTransport(BaseTransport): super(EMDLaplaceTransport, self).fit(Xs, ys, Xt, yt) returned_ = emd_laplace(a=self.mu_s, b=self.mu_t, xs=self.xs_, - xt=self.xt_, M=self.cost_, sim=self.similarity, eta=self.reg_lap, alpha=self.reg_src, + xt=self.xt_, M=self.cost_, reg=self.reg, sim=self.similarity, eta=self.reg_lap, alpha=self.reg_src, numItermax=self.max_iter, stopThr=self.tol, numInnerItermax=self.max_inner_iter, stopInnerThr=self.inner_tol, log=self.log, verbose=self.verbose) -- cgit v1.2.3 From 07463285317ed5c989040edcefb5c0e8cd3ac034 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 10:39:13 +0200 Subject: added kwargs to sim + doc --- ot/da.py | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/ot/da.py b/ot/da.py index 9e00dce..8e26e31 100644 --- a/ot/da.py +++ b/ot/da.py @@ -748,7 +748,7 @@ def OT_mapping_linear(xs, xt, reg=1e-6, ws=None, return A, b -def emd_laplace(a, b, xs, xt, M, sim, reg, eta, alpha, +def emd_laplace(a, b, xs, xt, M, reg, eta, alpha, numItermax, stopThr, numInnerItermax, stopInnerThr, log=False, verbose=False, **kwargs): r"""Solve the optimal transport problem (OT) with Laplacian regularization @@ -803,7 +803,11 @@ def emd_laplace(a, b, xs, xt, M, sim, reg, eta, alpha, Print information along iterations log : bool, optional record log if True - + kwargs : dict + Dictionary with attributes 'sim' ('knn' or 'gauss') and + 'param' (int, float or None) for similarity type and its parameter to be used. + If 'param' is None, it is computed as mean pairwise Euclidean distance over the data set + or set to 3 when sim is 'gauss' or 'knn', respectively. Returns ------- @@ -830,24 +834,28 @@ def emd_laplace(a, b, xs, xt, M, sim, reg, eta, alpha, ot.optim.cg : General regularized OT """ - if sim == 'gauss': - if 'rbfparam' not in kwargs: - kwargs['rbfparam'] = 1 / (2 * (np.mean(dist(xs, xs, 'sqeuclidean')) ** 2)) - sS = kernel(xs, xs, method=kwargs['sim'], sigma=kwargs['rbfparam']) - sT = kernel(xt, xt, method=kwargs['sim'], sigma=kwargs['rbfparam']) + if not isinstance(kwargs['param'], (int, float, type(None))): + raise ValueError( + 'Similarity parameter should be an int or a float. Got {type} instead.'.format(type=type(kwargs['param']))) + + if kwargs['sim'] == 'gauss': + if kwargs['param'] is None: + kwargs['param'] = 1 / (2 * (np.mean(dist(xs, xs, 'sqeuclidean')) ** 2)) + sS = kernel(xs, xs, method=kwargs['sim'], sigma=kwargs['param']) + sT = kernel(xt, xt, method=kwargs['sim'], sigma=kwargs['param']) - elif sim == 'knn': - if 'nn' not in kwargs: - kwargs['nn'] = 5 + elif kwargs['sim'] == 'knn': + if kwargs['param'] is None: + kwargs['param'] = 3 from sklearn.neighbors import kneighbors_graph - sS = kneighbors_graph(xs, kwargs['nn']).toarray() + sS = kneighbors_graph(X=xs, n_neighbors=int(kwargs['param'])).toarray() sS = (sS + sS.T) / 2 - sT = kneighbors_graph(xt, kwargs['nn']).toarray() + sT = kneighbors_graph(xt, n_neighbors=int(kwargs['param'])).toarray() sT = (sT + sT.T) / 2 else: - raise ValueError('Unknown similarity type {sim}. Currently supported similarity types are "knn" and "gauss".'.format(sim=sim)) + raise ValueError('Unknown similarity type {sim}. Currently supported similarity types are "knn" and "gauss".'.format(sim=kwargs['sim'])) lS = laplacian(sS) lT = laplacian(sT) @@ -1721,6 +1729,9 @@ class EMDLaplaceTransport(BaseTransport): can occur with large metric values. similarity : string, optional (default="knn") The similarity to use either knn or gaussian + similarity_param : int or float, optional (default=3) + Parameter for the similarity: number of nearest neighbors or bandwidth + if similarity="knn" or "gaussian", respectively. max_iter : int, optional (default=100) Max number of BCD iterations tol : float, optional (default=1e-5) @@ -1754,7 +1765,7 @@ class EMDLaplaceTransport(BaseTransport): """ def __init__(self, reg_type='pos', reg_lap=1., reg_src=1., alpha=0.5, - metric="sqeuclidean", norm=None, similarity="knn", max_iter=100, tol=1e-9, + metric="sqeuclidean", norm=None, similarity="knn", similarity_param=None, max_iter=100, tol=1e-9, max_inner_iter=100000, inner_tol=1e-9, log=False, verbose=False, distribution_estimation=distribution_estimation_uniform, out_of_sample_map='ferradans'): @@ -1765,6 +1776,7 @@ class EMDLaplaceTransport(BaseTransport): self.metric = metric self.norm = norm self.similarity = similarity + self.sim_param = similarity_param self.max_iter = max_iter self.tol = tol self.max_inner_iter = max_inner_iter @@ -1801,10 +1813,14 @@ class EMDLaplaceTransport(BaseTransport): super(EMDLaplaceTransport, self).fit(Xs, ys, Xt, yt) + kwargs = dict() + kwargs["sim"] = self.similarity + kwargs["param"] = self.sim_param + returned_ = emd_laplace(a=self.mu_s, b=self.mu_t, xs=self.xs_, - xt=self.xt_, M=self.cost_, reg=self.reg, sim=self.similarity, eta=self.reg_lap, alpha=self.reg_src, + xt=self.xt_, M=self.cost_, reg=self.reg, eta=self.reg_lap, alpha=self.reg_src, numItermax=self.max_iter, stopThr=self.tol, numInnerItermax=self.max_inner_iter, - stopInnerThr=self.inner_tol, log=self.log, verbose=self.verbose) + stopInnerThr=self.inner_tol, log=self.log, verbose=self.verbose, **kwargs) # coupling estimation if self.log: -- cgit v1.2.3 From 4eeaf49fa2289e6c48c83db1bbf17071f6fcdf96 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 12:53:16 +0200 Subject: conflit readme --- README.md | 248 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 123 insertions(+), 125 deletions(-) diff --git a/README.md b/README.md index 304f249..5b7f505 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,60 @@ # POT: Python Optimal Transport -[![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) -[![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) -[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/rflamary/POT) -[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) -[![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) -[![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) -[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/rflamary/POT/blob/master/LICENSE) - +import ot +[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) +[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) +[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) +[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) +[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) +[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) +[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. It provides the following solvers: -* OT Network Flow solver for the linear program/ Earth Movers Distance [1]. -* Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2], stabilized version [9][10] and greedy Sinkhorn [22] with optional GPU implementation (requires cupy). -* Sinkhorn divergence [23] and entropic regularization OT from empirical data. -* Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. -* Non regularized Wasserstein barycenters [16] with LP solver (only small scale). -* Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. -* Optimal transport for domain adaptation with group lasso and Laplacian regularization [5] -* Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. -* Linear OT [14] and Joint OT matrix and mapping estimation [8]. -* Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). -* Gromov-Wasserstein distances and barycenters ([13] and regularized [12]) -* 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]. -* JCPOT algorithm for multi-source domain adaptation with target shift [27]. - -Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. +* OT Network Flow solver for the linear program / Earth Movers Distance[1]. +* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). +* Sinkhorn divergence[23] and entropic regularization OT from empirical data. +* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. +* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). +* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. +* Optimal transport for domain adaptation with group lasso and Laplacian regularization[5] +* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. +* Linear OT[14] and Joint OT matrix and mapping estimation[8]. +* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). +* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) +* 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]. +* JCPOT algorithm for multi - source domain adaptation with target shift[27]. + +Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. #### Using and citing the toolbox If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: ``` + + @misc{flamary2017pot, -title={POT Python Optimal Transport library}, -author={Flamary, R{'e}mi and Courty, Nicolas}, -url={https://github.com/rflamary/POT}, -year={2017} -} + title = {POT Python Optimal Transport library}, + author = {Flamary, R{'e}mi and Courty, Nicolas}, + url = {https: // github.com / rflamary / POT}, + year = {2017} + } ``` ## Installation -The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: +The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: -- Numpy (>=1.11) -- Scipy (>=1.0) -- Cython (>=0.23) -- Matplotlib (>=1.5) +- Numpy ( >= 1.11) +- Scipy ( >= 1.0) +- Cython ( >= 0.23) +- Matplotlib ( >= 1.5) #### Pip installation @@ -68,35 +70,33 @@ pip install POT ``` or get the very latest version by downloading it and then running: ``` -python setup.py install --user # for user install (no root) +python setup.py install - -user # for user install (no root) ``` - #### Anaconda installation with conda-forge -If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies: +If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: ``` -conda install -c conda-forge pot +conda install - c conda - forge pot ``` #### Post installation check After a correct installation, you should be able to import the module without errors: ```python -import ot ``` Note that for easier access the module is name ot instead of pot. ### Dependencies -Some sub-modules require additional dependences which are discussed below +Some sub - modules require additional dependences which are discussed below -* **ot.dr** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: +* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: ``` pip install pymanopt autograd ``` -* **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). +* **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 need CUDA installed and a compatible GPU. @@ -107,159 +107,157 @@ obviously you need CUDA installed and a compatible GPU. * Import the toolbox ```python -import ot ``` * Compute Wasserstein distances ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -Wd=ot.emd2(a,b,M) # exact linear program -Wd_reg=ot.sinkhorn2(a,b,M,reg) # entropic regularized OT +Wd = ot.emd2(a, b, M) # exact linear program +Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT # if b is a matrix compute all distances to a and return a vector ``` * Compute OT matrix ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -T=ot.emd(a,b,M) # exact linear program -T_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT +T = ot.emd(a, b, M) # exact linear program +T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT ``` * Compute Wasserstein barycenter ```python # A is a n*d matrix containing d 1D histograms # M is the ground cost matrix -ba=ot.barycenter(A,M,reg) # reg is regularization parameter +ba = ot.barycenter(A, M, reg) # reg is regularization parameter ``` - - ### Examples and Notebooks -The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/). +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). -Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look: +Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: -* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb) -* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb) -* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb) -* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) +* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) +* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) +* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) +* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) -You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/). +You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). ## Acknowledgements This toolbox has been created and is maintained by -* [Rémi Flamary](http://remi.flamary.com/) -* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/) +* [Rémi Flamary](http: // remi.flamary.com / ) +* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) -The contributors to this library are +The contributors to this library are -* [Alexandre Gramfort](http://alexandre.gramfort.net/) -* [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/) -* [Michael Perrot](http://perso.univ-st-etienne.fr/pem82055/) (Mapping estimation) -* [Léo Gautheron](https://github.com/aje) (GPU implementation) -* [Nathalie Gayraud](https://www.linkedin.com/in/nathalie-t-h-gayraud/?ppe=1) -* [Stanislas Chambon](https://slasnista.github.io/) -* [Antoine Rolet](https://arolet.github.io/) -* Erwan Vautier (Gromov-Wasserstein) -* [Kilian Fatras](https://kilianfatras.github.io/) -* [Alain Rakotomamonjy](https://sites.google.com/site/alainrakotomamonjy/home) -* [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) -* [Ievgen Redko](https://ievred.github.io/) +* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) +* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) +* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) +* [Léo Gautheron](https: // github.com / aje)(GPU implementation) +* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) +* [Stanislas Chambon](https: // slasnista.github.io / ) +* [Antoine Rolet](https: // arolet.github.io / ) +* Erwan Vautier(Gromov - Wasserstein) +* [Kilian Fatras](https: // kilianfatras.github.io / ) +* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) +* [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) +* [Ievgen Redko](https: // ievred.github.io /) -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): +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): -* [Gabriel Peyré](http://gpeyre.github.io/) (Wasserstein Barycenters in Matlab) -* [Nicolas Bonneel](http://liris.cnrs.fr/~nbonneel/) ( C++ code for EMD) -* [Marco Cuturi](http://marcocuturi.net/) (Sinkhorn Knopp in Matlab/Cuda) +* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) +* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) +* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) ## Contributions and code of conduct -Every contribution is welcome and should respect the [contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md). +Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). ## Support You can ask questions and join the development discussion: -* On the [POT Slack channel](https://pot-toolbox.slack.com) -* On the POT [mailing list](https://mail.python.org/mm3/mailman3/lists/pot.python.org/) +* On the[POT Slack channel](https: // pot - toolbox.slack.com) +* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) -You can also post bug reports and feature requests in Github issues. Make sure to read our [guidelines](CONTRIBUTING.md) first. +You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. ## References -[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https://people.csail.mit.edu/sparis/publi/2011/sigasia/Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics (TOG) (Vol. 30, No. 6, p. 158). ACM. - -[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https://arxiv.org/pdf/1306.0895.pdf). In Advances in Neural Information Processing Systems (pp. 2292-2300). +[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. -[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https://arxiv.org/pdf/1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111-A1138. +[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). -[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https://hal.archives-ouvertes.fr/hal-01377236/document), Whorkshop on Hyperspectral Image and Signal Processing : Evolution in Remote Sensing (WHISPERS), 2016. +[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. -[5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https://arxiv.org/pdf/1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 +[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. -[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https://arxiv.org/pdf/1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853-1882. +[5] N. Courty +R. Flamary +D. Tuia +A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 -[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https://arxiv.org/pdf/1510.06567.pdf). arXiv preprint arXiv:1510.06567. +[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. -[8] M. Perrot, N. Courty, R. Flamary, A. Habrard (2016), [Mapping estimation for discrete optimal transport](http://remi.flamary.com/biblio/perrot2016mapping.pdf), Neural Information Processing Systems (NIPS). +[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. -[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https://arxiv.org/pdf/1610.06519.pdf). arXiv preprint arXiv:1610.06519. +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). -[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https://arxiv.org/pdf/1607.05816.pdf). arXiv preprint arXiv:1607.05816. +[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. -[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https://arxiv.org/pdf/1608.08063.pdf). arXiv preprint arXiv:1608.08063. +[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. -[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon (2016), [Gromov-Wasserstein averaging of kernel and distance matrices](http://proceedings.mlr.press/v48/peyre16.html) International Conference on Machine Learning (ICML). +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. -[13] Mémoli, Facundo (2011). [Gromov–Wasserstein distances and the metric approach to object matching](https://media.adelaide.edu.au/acvt/Publications/2011/2011-Gromov%E2%80%93Wasserstein%20Distances%20and%20the%20Metric%20Approach%20to%20Object%20Matching.pdf). Foundations of computational mathematics 11.4 : 417-487. +[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). -[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https://link.springer.com/article/10.1007/BF00934745), Journal of Optimization Theory and Applications Vol 43. +[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. -[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https://arxiv.org/pdf/1803.00567.pdf) . +[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. -[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https://hal.archives-ouvertes.fr/hal-00637399/document). SIAM Journal on Mathematical Analysis, 43(2), 904-924. +[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . -[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https://arxiv.org/abs/1710.06276). Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics (AISTATS). +[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. -[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016) [Stochastic Optimization for Large-scale Optimal Transport](https://arxiv.org/abs/1605.08527). Advances in Neural Information Processing Systems (2016). +[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). -[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A.& Blondel, M. [Large-scale Optimal Transport and Mapping Estimation](https://arxiv.org/pdf/1711.02283.pdf). International Conference on Learning Representation (2018) +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). -[20] Cuturi, M. and Doucet, A. (2014) [Fast Computation of Wasserstein Barycenters](http://proceedings.mlr.press/v32/cuturi14.html). International Conference in Machine Learning +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) -[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https://dl.acm.org/citation.cfm?id=2766963). ACM Transactions on Graphics (TOG), 34(4), 66. +[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning -[22] J. Altschuler, J.Weed, P. Rigollet, (2017) [Near-linear time approximation algorithms for optimal transport via Sinkhorn iteration](https://papers.nips.cc/paper/6792-near-linear-time-approximation-algorithms-for-optimal-transport-via-sinkhorn-iteration.pdf), Advances in Neural Information Processing Systems (NIPS) 31 +[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. -[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https://arxiv.org/abs/1706.00292), Proceedings of the Twenty-First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 +[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 -[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). +[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 -[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). +[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). -[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). +[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). -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. +[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). -[28] Flamary R., Courty N., Tuia D., Rakotomamonjy A. (2014). [Optimal transport with Laplacian regularization: Applications to domain adaptation and shape matching](https://remi.flamary.com/biblio/flamary2014optlaplace.pdf), NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. -- cgit v1.2.3 From 5eedfcf89171163c2bc60cf51c438b34fc514caf Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 12:54:25 +0200 Subject: conflit readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5b7f505..39acdd3 100644 --- a/README.md +++ b/README.md @@ -261,3 +261,7 @@ A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org [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). [27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. + +[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge - Ampere obstacle problems](http: // www.math.toronto.edu / ~mccann / papers / annals2010.pdf), Annals of mathematics, 673 - 730. + +[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov - Wasserstein with Applications on Positive - Unlabeled Learning](https: // arxiv.org / abs / 2002.08276), arXiv preprint arXiv: 2002.08276. -- cgit v1.2.3 From 6da7586f0f08ca07a380d23ea96281e1511d333c Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 12:57:33 +0200 Subject: conflit readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 39acdd3..5b7f505 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,3 @@ A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org [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). [27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. - -[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge - Ampere obstacle problems](http: // www.math.toronto.edu / ~mccann / papers / annals2010.pdf), Annals of mathematics, 673 - 730. - -[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov - Wasserstein with Applications on Positive - Unlabeled Learning](https: // arxiv.org / abs / 2002.08276), arXiv preprint arXiv: 2002.08276. -- cgit v1.2.3 From 72b1a2822be81a877210d0bf11520ae4559b6d51 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:00:51 +0200 Subject: conflit readme --- README.md | 250 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 127 insertions(+), 123 deletions(-) diff --git a/README.md b/README.md index 5b7f505..28d2b2a 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,59 @@ # POT: Python Optimal Transport -import ot -[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) -[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) -[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) -[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) -[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) -[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) -[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) +[![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) +[![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) +[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/rflamary/POT) +[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) +[![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) +[![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) +[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/rflamary/POT/blob/master/LICENSE) + This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. It provides the following solvers: -* OT Network Flow solver for the linear program / Earth Movers Distance[1]. -* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). -* Sinkhorn divergence[23] and entropic regularization OT from empirical data. -* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. -* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). -* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. -* Optimal transport for domain adaptation with group lasso and Laplacian regularization[5] -* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. -* Linear OT[14] and Joint OT matrix and mapping estimation[8]. -* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). -* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) -* 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]. -* JCPOT algorithm for multi - source domain adaptation with target shift[27]. - -Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. +* OT Network Flow solver for the linear program/ Earth Movers Distance [1]. +* Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2], stabilized version [9][10] and greedy Sinkhorn [22] with optional GPU implementation (requires cupy). +* Sinkhorn divergence [23] and entropic regularization OT from empirical data. +* Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. +* Non regularized Wasserstein barycenters [16] with LP solver (only small scale). +* Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. +* Optimal transport for domain adaptation with group lasso regularization [5] +* Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. +* Linear OT [14] and Joint OT matrix and mapping estimation [8]. +* Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). +* Gromov-Wasserstein distances and barycenters ([13] and regularized [12]) +* 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]. +* JCPOT algorithm for multi-source domain adaptation with target shift [27]. +* Partial Wasserstein and Gromov-Wasserstein (exact [29] and entropic [3] formulations). + +Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. #### Using and citing the toolbox If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: ``` - - @misc{flamary2017pot, - title = {POT Python Optimal Transport library}, - author = {Flamary, R{'e}mi and Courty, Nicolas}, - url = {https: // github.com / rflamary / POT}, - year = {2017} - } +title={POT Python Optimal Transport library}, +author={Flamary, R{'e}mi and Courty, Nicolas}, +url={https://github.com/rflamary/POT}, +year={2017} +} ``` ## Installation -The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: +The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: -- Numpy ( >= 1.11) -- Scipy ( >= 1.0) -- Cython ( >= 0.23) -- Matplotlib ( >= 1.5) +- Numpy (>=1.11) +- Scipy (>=1.0) +- Cython (>=0.23) +- Matplotlib (>=1.5) #### Pip installation @@ -70,33 +69,35 @@ pip install POT ``` or get the very latest version by downloading it and then running: ``` -python setup.py install - -user # for user install (no root) +python setup.py install --user # for user install (no root) ``` + #### Anaconda installation with conda-forge -If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: +If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies: ``` -conda install - c conda - forge pot +conda install -c conda-forge pot ``` #### Post installation check After a correct installation, you should be able to import the module without errors: ```python +import ot ``` Note that for easier access the module is name ot instead of pot. ### Dependencies -Some sub - modules require additional dependences which are discussed below +Some sub-modules require additional dependences which are discussed below -* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: +* **ot.dr** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: ``` pip install pymanopt autograd ``` -* **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). +* **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 need CUDA installed and a compatible GPU. @@ -107,157 +108,160 @@ obviously you need CUDA installed and a compatible GPU. * Import the toolbox ```python +import ot ``` * Compute Wasserstein distances ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -Wd = ot.emd2(a, b, M) # exact linear program -Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT +Wd=ot.emd2(a,b,M) # exact linear program +Wd_reg=ot.sinkhorn2(a,b,M,reg) # entropic regularized OT # if b is a matrix compute all distances to a and return a vector ``` * Compute OT matrix ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -T = ot.emd(a, b, M) # exact linear program -T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT +T=ot.emd(a,b,M) # exact linear program +T_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT ``` * Compute Wasserstein barycenter ```python # A is a n*d matrix containing d 1D histograms # M is the ground cost matrix -ba = ot.barycenter(A, M, reg) # reg is regularization parameter +ba=ot.barycenter(A,M,reg) # reg is regularization parameter ``` + + ### Examples and Notebooks -The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/). -Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: +Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look: -* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) -* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) -* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) -* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) +* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb) +* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb) +* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb) +* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) -You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). +You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/). ## Acknowledgements This toolbox has been created and is maintained by -* [Rémi Flamary](http: // remi.flamary.com / ) -* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) +* [Rémi Flamary](http://remi.flamary.com/) +* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/) -The contributors to this library are +The contributors to this library are -* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) -* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) -* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) -* [Léo Gautheron](https: // github.com / aje)(GPU implementation) -* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) -* [Stanislas Chambon](https: // slasnista.github.io / ) -* [Antoine Rolet](https: // arolet.github.io / ) -* Erwan Vautier(Gromov - Wasserstein) -* [Kilian Fatras](https: // kilianfatras.github.io / ) -* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) -* [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) -* [Ievgen Redko](https: // ievred.github.io /) +* [Alexandre Gramfort](http://alexandre.gramfort.net/) +* [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/) +* [Michael Perrot](http://perso.univ-st-etienne.fr/pem82055/) (Mapping estimation) +* [Léo Gautheron](https://github.com/aje) (GPU implementation) +* [Nathalie Gayraud](https://www.linkedin.com/in/nathalie-t-h-gayraud/?ppe=1) +* [Stanislas Chambon](https://slasnista.github.io/) +* [Antoine Rolet](https://arolet.github.io/) +* Erwan Vautier (Gromov-Wasserstein) +* [Kilian Fatras](https://kilianfatras.github.io/) +* [Alain Rakotomamonjy](https://sites.google.com/site/alainrakotomamonjy/home) +* [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): +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): -* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) -* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) -* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) +* [Gabriel Peyré](http://gpeyre.github.io/) (Wasserstein Barycenters in Matlab) +* [Nicolas Bonneel](http://liris.cnrs.fr/~nbonneel/) ( C++ code for EMD) +* [Marco Cuturi](http://marcocuturi.net/) (Sinkhorn Knopp in Matlab/Cuda) ## Contributions and code of conduct -Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). +Every contribution is welcome and should respect the [contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md). ## Support You can ask questions and join the development discussion: -* On the[POT Slack channel](https: // pot - toolbox.slack.com) -* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) +* On the [POT Slack channel](https://pot-toolbox.slack.com) +* On the POT [mailing list](https://mail.python.org/mm3/mailman3/lists/pot.python.org/) -You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. +You can also post bug reports and feature requests in Github issues. Make sure to read our [guidelines](CONTRIBUTING.md) first. ## References -[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. +[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https://people.csail.mit.edu/sparis/publi/2011/sigasia/Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics (TOG) (Vol. 30, No. 6, p. 158). ACM. + +[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https://arxiv.org/pdf/1306.0895.pdf). In Advances in Neural Information Processing Systems (pp. 2292-2300). + +[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https://arxiv.org/pdf/1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111-A1138. -[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). +[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https://hal.archives-ouvertes.fr/hal-01377236/document), Whorkshop on Hyperspectral Image and Signal Processing : Evolution in Remote Sensing (WHISPERS), 2016. -[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. +[5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https://arxiv.org/pdf/1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 -[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. +[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https://arxiv.org/pdf/1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853-1882. -[5] N. Courty -R. Flamary -D. Tuia -A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 +[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https://arxiv.org/pdf/1510.06567.pdf). arXiv preprint arXiv:1510.06567. -[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard (2016), [Mapping estimation for discrete optimal transport](http://remi.flamary.com/biblio/perrot2016mapping.pdf), Neural Information Processing Systems (NIPS). -[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. +[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https://arxiv.org/pdf/1610.06519.pdf). arXiv preprint arXiv:1610.06519. -[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). +[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https://arxiv.org/pdf/1607.05816.pdf). arXiv preprint arXiv:1607.05816. -[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https://arxiv.org/pdf/1608.08063.pdf). arXiv preprint arXiv:1608.08063. -[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. +[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon (2016), [Gromov-Wasserstein averaging of kernel and distance matrices](http://proceedings.mlr.press/v48/peyre16.html) International Conference on Machine Learning (ICML). -[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. +[13] Mémoli, Facundo (2011). [Gromov–Wasserstein distances and the metric approach to object matching](https://media.adelaide.edu.au/acvt/Publications/2011/2011-Gromov%E2%80%93Wasserstein%20Distances%20and%20the%20Metric%20Approach%20to%20Object%20Matching.pdf). Foundations of computational mathematics 11.4 : 417-487. -[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). +[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https://link.springer.com/article/10.1007/BF00934745), Journal of Optimization Theory and Applications Vol 43. -[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. +[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https://arxiv.org/pdf/1803.00567.pdf) . -[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. +[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https://hal.archives-ouvertes.fr/hal-00637399/document). SIAM Journal on Mathematical Analysis, 43(2), 904-924. -[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . +[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https://arxiv.org/abs/1710.06276). Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics (AISTATS). -[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016) [Stochastic Optimization for Large-scale Optimal Transport](https://arxiv.org/abs/1605.08527). Advances in Neural Information Processing Systems (2016). -[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A.& Blondel, M. [Large-scale Optimal Transport and Mapping Estimation](https://arxiv.org/pdf/1711.02283.pdf). International Conference on Learning Representation (2018) -[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). +[20] Cuturi, M. and Doucet, A. (2014) [Fast Computation of Wasserstein Barycenters](http://proceedings.mlr.press/v32/cuturi14.html). International Conference in Machine Learning -[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) +[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https://dl.acm.org/citation.cfm?id=2766963). ACM Transactions on Graphics (TOG), 34(4), 66. -[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning +[22] J. Altschuler, J.Weed, P. Rigollet, (2017) [Near-linear time approximation algorithms for optimal transport via Sinkhorn iteration](https://papers.nips.cc/paper/6792-near-linear-time-approximation-algorithms-for-optimal-transport-via-sinkhorn-iteration.pdf), Advances in Neural Information Processing Systems (NIPS) 31 -[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. +[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https://arxiv.org/abs/1706.00292), Proceedings of the Twenty-First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 -[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 +[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). -[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 +[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). -[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). +[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). -[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). +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. -[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). +[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge-Ampere obstacle problems](http://www.math.toronto.edu/~mccann/papers/annals2010.pdf), Annals of mathematics, 673-730. -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. +[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov-Wasserstein with Applications on Positive-Unlabeled Learning](https://arxiv.org/abs/2002.08276), arXiv preprint arXiv:2002.08276. -- cgit v1.2.3 From d25d9e8401b0bbdbecadedce977fd4a3a4fe6c87 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:01:47 +0200 Subject: conflit readme --- README.md | 250 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/README.md b/README.md index 28d2b2a..57a3dcf 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,61 @@ # POT: Python Optimal Transport -[![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) -[![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) -[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/rflamary/POT) -[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) -[![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) -[![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) -[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/rflamary/POT/blob/master/LICENSE) - +import ot +[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) +[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) +[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) +[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) +[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) +[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) +[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. It provides the following solvers: -* OT Network Flow solver for the linear program/ Earth Movers Distance [1]. -* Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2], stabilized version [9][10] and greedy Sinkhorn [22] with optional GPU implementation (requires cupy). -* Sinkhorn divergence [23] and entropic regularization OT from empirical data. -* Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. -* Non regularized Wasserstein barycenters [16] with LP solver (only small scale). -* Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. -* Optimal transport for domain adaptation with group lasso regularization [5] -* Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. -* Linear OT [14] and Joint OT matrix and mapping estimation [8]. -* Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). -* Gromov-Wasserstein distances and barycenters ([13] and regularized [12]) -* 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]. -* JCPOT algorithm for multi-source domain adaptation with target shift [27]. -* Partial Wasserstein and Gromov-Wasserstein (exact [29] and entropic [3] formulations). - -Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. +* OT Network Flow solver for the linear program / Earth Movers Distance[1]. +* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). +* Sinkhorn divergence[23] and entropic regularization OT from empirical data. +* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. +* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). +* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. +* Optimal transport for domain adaptation with group lasso regularization[5] +* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. +* Linear OT[14] and Joint OT matrix and mapping estimation[8]. +* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). +* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) +* 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]. +* JCPOT algorithm for multi - source domain adaptation with target shift[27]. +* Partial Wasserstein and Gromov - Wasserstein(exact[29] and entropic[3] formulations). + +Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. #### Using and citing the toolbox If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: ``` + + @misc{flamary2017pot, -title={POT Python Optimal Transport library}, -author={Flamary, R{'e}mi and Courty, Nicolas}, -url={https://github.com/rflamary/POT}, -year={2017} -} + title = {POT Python Optimal Transport library}, + author = {Flamary, R{'e}mi and Courty, Nicolas}, + url = {https: // github.com / rflamary / POT}, + year = {2017} + } ``` ## Installation -The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: +The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: -- Numpy (>=1.11) -- Scipy (>=1.0) -- Cython (>=0.23) -- Matplotlib (>=1.5) +- Numpy ( >= 1.11) +- Scipy ( >= 1.0) +- Cython ( >= 0.23) +- Matplotlib ( >= 1.5) #### Pip installation @@ -69,35 +71,33 @@ pip install POT ``` or get the very latest version by downloading it and then running: ``` -python setup.py install --user # for user install (no root) +python setup.py install - -user # for user install (no root) ``` - #### Anaconda installation with conda-forge -If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies: +If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: ``` -conda install -c conda-forge pot +conda install - c conda - forge pot ``` #### Post installation check After a correct installation, you should be able to import the module without errors: ```python -import ot ``` Note that for easier access the module is name ot instead of pot. ### Dependencies -Some sub-modules require additional dependences which are discussed below +Some sub - modules require additional dependences which are discussed below -* **ot.dr** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: +* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: ``` pip install pymanopt autograd ``` -* **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). +* **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 need CUDA installed and a compatible GPU. @@ -108,160 +108,160 @@ obviously you need CUDA installed and a compatible GPU. * Import the toolbox ```python -import ot ``` * Compute Wasserstein distances ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -Wd=ot.emd2(a,b,M) # exact linear program -Wd_reg=ot.sinkhorn2(a,b,M,reg) # entropic regularized OT +Wd = ot.emd2(a, b, M) # exact linear program +Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT # if b is a matrix compute all distances to a and return a vector ``` * Compute OT matrix ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -T=ot.emd(a,b,M) # exact linear program -T_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT +T = ot.emd(a, b, M) # exact linear program +T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT ``` * Compute Wasserstein barycenter ```python # A is a n*d matrix containing d 1D histograms # M is the ground cost matrix -ba=ot.barycenter(A,M,reg) # reg is regularization parameter +ba = ot.barycenter(A, M, reg) # reg is regularization parameter ``` - - ### Examples and Notebooks -The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/). +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). -Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look: +Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: -* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb) -* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb) -* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb) -* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) +* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) +* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) +* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) +* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) -You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/). +You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). ## Acknowledgements This toolbox has been created and is maintained by -* [Rémi Flamary](http://remi.flamary.com/) -* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/) +* [Rémi Flamary](http: // remi.flamary.com / ) +* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) -The contributors to this library are +The contributors to this library are -* [Alexandre Gramfort](http://alexandre.gramfort.net/) -* [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/) -* [Michael Perrot](http://perso.univ-st-etienne.fr/pem82055/) (Mapping estimation) -* [Léo Gautheron](https://github.com/aje) (GPU implementation) -* [Nathalie Gayraud](https://www.linkedin.com/in/nathalie-t-h-gayraud/?ppe=1) -* [Stanislas Chambon](https://slasnista.github.io/) -* [Antoine Rolet](https://arolet.github.io/) -* Erwan Vautier (Gromov-Wasserstein) -* [Kilian Fatras](https://kilianfatras.github.io/) -* [Alain Rakotomamonjy](https://sites.google.com/site/alainrakotomamonjy/home) -* [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) +* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) +* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) +* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) +* [Léo Gautheron](https: // github.com / aje)(GPU implementation) +* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) +* [Stanislas Chambon](https: // slasnista.github.io / ) +* [Antoine Rolet](https: // arolet.github.io / ) +* Erwan Vautier(Gromov - Wasserstein) +* [Kilian Fatras](https: // kilianfatras.github.io / ) +* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) +* [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): +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): -* [Gabriel Peyré](http://gpeyre.github.io/) (Wasserstein Barycenters in Matlab) -* [Nicolas Bonneel](http://liris.cnrs.fr/~nbonneel/) ( C++ code for EMD) -* [Marco Cuturi](http://marcocuturi.net/) (Sinkhorn Knopp in Matlab/Cuda) +* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) +* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) +* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) ## Contributions and code of conduct -Every contribution is welcome and should respect the [contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md). +Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). ## Support You can ask questions and join the development discussion: -* On the [POT Slack channel](https://pot-toolbox.slack.com) -* On the POT [mailing list](https://mail.python.org/mm3/mailman3/lists/pot.python.org/) +* On the[POT Slack channel](https: // pot - toolbox.slack.com) +* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) -You can also post bug reports and feature requests in Github issues. Make sure to read our [guidelines](CONTRIBUTING.md) first. +You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. ## References -[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https://people.csail.mit.edu/sparis/publi/2011/sigasia/Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics (TOG) (Vol. 30, No. 6, p. 158). ACM. +[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. -[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https://arxiv.org/pdf/1306.0895.pdf). In Advances in Neural Information Processing Systems (pp. 2292-2300). +[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). -[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https://arxiv.org/pdf/1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111-A1138. +[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. -[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https://hal.archives-ouvertes.fr/hal-01377236/document), Whorkshop on Hyperspectral Image and Signal Processing : Evolution in Remote Sensing (WHISPERS), 2016. +[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. -[5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https://arxiv.org/pdf/1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 +[5] N. Courty +R. Flamary +D. Tuia +A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 -[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https://arxiv.org/pdf/1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853-1882. +[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. -[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https://arxiv.org/pdf/1510.06567.pdf). arXiv preprint arXiv:1510.06567. +[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. -[8] M. Perrot, N. Courty, R. Flamary, A. Habrard (2016), [Mapping estimation for discrete optimal transport](http://remi.flamary.com/biblio/perrot2016mapping.pdf), Neural Information Processing Systems (NIPS). +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). -[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https://arxiv.org/pdf/1610.06519.pdf). arXiv preprint arXiv:1610.06519. +[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. -[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https://arxiv.org/pdf/1607.05816.pdf). arXiv preprint arXiv:1607.05816. +[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. -[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https://arxiv.org/pdf/1608.08063.pdf). arXiv preprint arXiv:1608.08063. +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. -[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon (2016), [Gromov-Wasserstein averaging of kernel and distance matrices](http://proceedings.mlr.press/v48/peyre16.html) International Conference on Machine Learning (ICML). +[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). -[13] Mémoli, Facundo (2011). [Gromov–Wasserstein distances and the metric approach to object matching](https://media.adelaide.edu.au/acvt/Publications/2011/2011-Gromov%E2%80%93Wasserstein%20Distances%20and%20the%20Metric%20Approach%20to%20Object%20Matching.pdf). Foundations of computational mathematics 11.4 : 417-487. +[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. -[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https://link.springer.com/article/10.1007/BF00934745), Journal of Optimization Theory and Applications Vol 43. +[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. -[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https://arxiv.org/pdf/1803.00567.pdf) . +[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . -[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https://hal.archives-ouvertes.fr/hal-00637399/document). SIAM Journal on Mathematical Analysis, 43(2), 904-924. +[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. -[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https://arxiv.org/abs/1710.06276). Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics (AISTATS). +[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). -[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016) [Stochastic Optimization for Large-scale Optimal Transport](https://arxiv.org/abs/1605.08527). Advances in Neural Information Processing Systems (2016). +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). -[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A.& Blondel, M. [Large-scale Optimal Transport and Mapping Estimation](https://arxiv.org/pdf/1711.02283.pdf). International Conference on Learning Representation (2018) +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) -[20] Cuturi, M. and Doucet, A. (2014) [Fast Computation of Wasserstein Barycenters](http://proceedings.mlr.press/v32/cuturi14.html). International Conference in Machine Learning +[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning -[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https://dl.acm.org/citation.cfm?id=2766963). ACM Transactions on Graphics (TOG), 34(4), 66. +[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. -[22] J. Altschuler, J.Weed, P. Rigollet, (2017) [Near-linear time approximation algorithms for optimal transport via Sinkhorn iteration](https://papers.nips.cc/paper/6792-near-linear-time-approximation-algorithms-for-optimal-transport-via-sinkhorn-iteration.pdf), Advances in Neural Information Processing Systems (NIPS) 31 +[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 -[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https://arxiv.org/abs/1706.00292), Proceedings of the Twenty-First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 +[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 -[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). +[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. (2015). [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). +[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). -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. -[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge-Ampere obstacle problems](http://www.math.toronto.edu/~mccann/papers/annals2010.pdf), Annals of mathematics, 673-730. +[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge - Ampere obstacle problems](http: // www.math.toronto.edu / ~mccann / papers / annals2010.pdf), Annals of mathematics, 673 - 730. -[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov-Wasserstein with Applications on Positive-Unlabeled Learning](https://arxiv.org/abs/2002.08276), arXiv preprint arXiv:2002.08276. +[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov - Wasserstein with Applications on Positive - Unlabeled Learning](https: // arxiv.org / abs / 2002.08276), arXiv preprint arXiv: 2002.08276. -- cgit v1.2.3 From 6ea4169133523b74b38c5fcca1c45de7acdf4226 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:08:04 +0200 Subject: clean readme --- README.md | 267 -------------------------------------------------------------- 1 file changed, 267 deletions(-) diff --git a/README.md b/README.md index 57a3dcf..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,267 +0,0 @@ -# POT: Python Optimal Transport - -import ot -[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) -[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) -[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) -[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) -[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) -[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) -[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) - - -This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. - -It provides the following solvers: - -* OT Network Flow solver for the linear program / Earth Movers Distance[1]. -* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). -* Sinkhorn divergence[23] and entropic regularization OT from empirical data. -* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. -* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). -* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. -* Optimal transport for domain adaptation with group lasso regularization[5] -* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. -* Linear OT[14] and Joint OT matrix and mapping estimation[8]. -* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). -* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) -* 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]. -* JCPOT algorithm for multi - source domain adaptation with target shift[27]. -* Partial Wasserstein and Gromov - Wasserstein(exact[29] and entropic[3] formulations). - -Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. - -#### Using and citing the toolbox - -If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: -``` - - -@misc{flamary2017pot, - title = {POT Python Optimal Transport library}, - author = {Flamary, R{'e}mi and Courty, Nicolas}, - url = {https: // github.com / rflamary / POT}, - year = {2017} - } -``` - -## Installation - -The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: - -- Numpy ( >= 1.11) -- Scipy ( >= 1.0) -- Cython ( >= 0.23) -- Matplotlib ( >= 1.5) - -#### Pip installation - -Note that due to a limitation of pip, `cython` and `numpy` need to be installed -prior to installing POT. This can be done easily with -``` -pip install numpy cython -``` - -You can install the toolbox through PyPI with: -``` -pip install POT -``` -or get the very latest version by downloading it and then running: -``` -python setup.py install - -user # for user install (no root) -``` - - -#### Anaconda installation with conda-forge - -If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: -``` -conda install - c conda - forge pot -``` - -#### Post installation check -After a correct installation, you should be able to import the module without errors: -```python -``` -Note that for easier access the module is name ot instead of pot. - - -### Dependencies - -Some sub - modules require additional dependences which are discussed below - -* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: -``` -pip install pymanopt autograd -``` -* **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 need CUDA installed and a compatible GPU. - -## Examples - -### Short examples - -* Import the toolbox -```python -``` -* Compute Wasserstein distances -```python -# a,b are 1D histograms (sum to 1 and positive) -# M is the ground cost matrix -Wd = ot.emd2(a, b, M) # exact linear program -Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT -# if b is a matrix compute all distances to a and return a vector -``` -* Compute OT matrix -```python -# a,b are 1D histograms (sum to 1 and positive) -# M is the ground cost matrix -T = ot.emd(a, b, M) # exact linear program -T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT -``` -* Compute Wasserstein barycenter -```python -# A is a n*d matrix containing d 1D histograms -# M is the ground cost matrix -ba = ot.barycenter(A, M, reg) # reg is regularization parameter -``` - - -### Examples and Notebooks - -The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). - - -Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: - -* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) -* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) -* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) -* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) - - -You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). - -## Acknowledgements - -This toolbox has been created and is maintained by - -* [Rémi Flamary](http: // remi.flamary.com / ) -* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) - -The contributors to this library are - -* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) -* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) -* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) -* [Léo Gautheron](https: // github.com / aje)(GPU implementation) -* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) -* [Stanislas Chambon](https: // slasnista.github.io / ) -* [Antoine Rolet](https: // arolet.github.io / ) -* Erwan Vautier(Gromov - Wasserstein) -* [Kilian Fatras](https: // kilianfatras.github.io / ) -* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) -* [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): - -* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) -* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) -* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) - - -## Contributions and code of conduct - -Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). - -## Support - -You can ask questions and join the development discussion: - -* On the[POT Slack channel](https: // pot - toolbox.slack.com) -* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) - - -You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. - -## References - -[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. - -[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). - -[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. - -[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. - -[5] N. Courty -R. Flamary -D. Tuia -A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 - -[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. - -[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. - -[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). - -[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. - -[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. - -[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. - -[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). - -[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. - -[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. - -[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . - -[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. - -[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). - -[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). - -[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) - -[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning - -[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. - -[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 - -[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 - -[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. (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). - -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. - -[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge - Ampere obstacle problems](http: // www.math.toronto.edu / ~mccann / papers / annals2010.pdf), Annals of mathematics, 673 - 730. - -[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov - Wasserstein with Applications on Positive - Unlabeled Learning](https: // arxiv.org / abs / 2002.08276), arXiv preprint arXiv: 2002.08276. -- cgit v1.2.3 From d12ccc2880fcb413efae2e6e4663fe9704c8aa85 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:09:46 +0200 Subject: clean readme --- README.md | 267 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 267 insertions(+) diff --git a/README.md b/README.md index e69de29..57a3dcf 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,267 @@ +# POT: Python Optimal Transport + +import ot +[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) +[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) +[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) +[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) +[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) +[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) +[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) + + +This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. + +It provides the following solvers: + +* OT Network Flow solver for the linear program / Earth Movers Distance[1]. +* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). +* Sinkhorn divergence[23] and entropic regularization OT from empirical data. +* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. +* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). +* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. +* Optimal transport for domain adaptation with group lasso regularization[5] +* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. +* Linear OT[14] and Joint OT matrix and mapping estimation[8]. +* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). +* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) +* 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]. +* JCPOT algorithm for multi - source domain adaptation with target shift[27]. +* Partial Wasserstein and Gromov - Wasserstein(exact[29] and entropic[3] formulations). + +Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. + +#### Using and citing the toolbox + +If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: +``` + + +@misc{flamary2017pot, + title = {POT Python Optimal Transport library}, + author = {Flamary, R{'e}mi and Courty, Nicolas}, + url = {https: // github.com / rflamary / POT}, + year = {2017} + } +``` + +## Installation + +The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: + +- Numpy ( >= 1.11) +- Scipy ( >= 1.0) +- Cython ( >= 0.23) +- Matplotlib ( >= 1.5) + +#### Pip installation + +Note that due to a limitation of pip, `cython` and `numpy` need to be installed +prior to installing POT. This can be done easily with +``` +pip install numpy cython +``` + +You can install the toolbox through PyPI with: +``` +pip install POT +``` +or get the very latest version by downloading it and then running: +``` +python setup.py install - -user # for user install (no root) +``` + + +#### Anaconda installation with conda-forge + +If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: +``` +conda install - c conda - forge pot +``` + +#### Post installation check +After a correct installation, you should be able to import the module without errors: +```python +``` +Note that for easier access the module is name ot instead of pot. + + +### Dependencies + +Some sub - modules require additional dependences which are discussed below + +* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: +``` +pip install pymanopt autograd +``` +* **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 need CUDA installed and a compatible GPU. + +## Examples + +### Short examples + +* Import the toolbox +```python +``` +* Compute Wasserstein distances +```python +# a,b are 1D histograms (sum to 1 and positive) +# M is the ground cost matrix +Wd = ot.emd2(a, b, M) # exact linear program +Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT +# if b is a matrix compute all distances to a and return a vector +``` +* Compute OT matrix +```python +# a,b are 1D histograms (sum to 1 and positive) +# M is the ground cost matrix +T = ot.emd(a, b, M) # exact linear program +T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT +``` +* Compute Wasserstein barycenter +```python +# A is a n*d matrix containing d 1D histograms +# M is the ground cost matrix +ba = ot.barycenter(A, M, reg) # reg is regularization parameter +``` + + +### Examples and Notebooks + +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). + + +Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: + +* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) +* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) +* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) +* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) + + +You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). + +## Acknowledgements + +This toolbox has been created and is maintained by + +* [Rémi Flamary](http: // remi.flamary.com / ) +* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) + +The contributors to this library are + +* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) +* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) +* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) +* [Léo Gautheron](https: // github.com / aje)(GPU implementation) +* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) +* [Stanislas Chambon](https: // slasnista.github.io / ) +* [Antoine Rolet](https: // arolet.github.io / ) +* Erwan Vautier(Gromov - Wasserstein) +* [Kilian Fatras](https: // kilianfatras.github.io / ) +* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) +* [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): + +* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) +* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) +* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) + + +## Contributions and code of conduct + +Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). + +## Support + +You can ask questions and join the development discussion: + +* On the[POT Slack channel](https: // pot - toolbox.slack.com) +* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) + + +You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. + +## References + +[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. + +[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). + +[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. + +[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. + +[5] N. Courty +R. Flamary +D. Tuia +A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 + +[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. + +[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. + +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). + +[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. + +[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. + +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. + +[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). + +[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. + +[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. + +[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . + +[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. + +[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). + +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). + +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) + +[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning + +[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. + +[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 + +[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 + +[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. (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). + +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. + +[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge - Ampere obstacle problems](http: // www.math.toronto.edu / ~mccann / papers / annals2010.pdf), Annals of mathematics, 673 - 730. + +[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov - Wasserstein with Applications on Positive - Unlabeled Learning](https: // arxiv.org / abs / 2002.08276), arXiv preprint arXiv: 2002.08276. -- cgit v1.2.3 From 55b5da6e04653b30ea69f56f1fc28db33ddb67a9 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:24:18 +0200 Subject: hell --- README.md | 250 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/README.md b/README.md index 57a3dcf..28d2b2a 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,59 @@ # POT: Python Optimal Transport -import ot -[![PyPI version](https: // badge.fury.io / py / POT.svg)](https: // badge.fury.io / py / POT) -[![Anaconda Cloud](https: // anaconda.org / conda - forge / pot / badges / version.svg)](https: // anaconda.org / conda - forge / pot) -[![Build Status](https: // travis - ci.org / rflamary / POT.svg?branch=master)](https: // travis - ci.org / rflamary / POT) -[![Documentation Status](https: // readthedocs.org / projects / pot / badge /?version=latest)](http: // pot.readthedocs.io / en / latest /?badge=latest) -[![Downloads](https: // pepy.tech / badge / pot)](https: // pepy.tech / project / pot) -[![Anaconda downloads](https: // anaconda.org / conda - forge / pot / badges / downloads.svg)](https: // anaconda.org / conda - forge / pot) -[![License](https: // anaconda.org / conda - forge / pot / badges / license.svg)](https: // github.com / rflamary / POT / blob / master / LICENSE) +[![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) +[![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) +[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/rflamary/POT) +[![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) +[![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) +[![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) +[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/rflamary/POT/blob/master/LICENSE) + This open source Python library provide several solvers for optimization problems related to Optimal Transport for signal, image processing and machine learning. It provides the following solvers: -* OT Network Flow solver for the linear program / Earth Movers Distance[1]. -* Entropic regularization OT solver with Sinkhorn Knopp Algorithm[2], stabilized version[9][10] and greedy Sinkhorn[22] with optional GPU implementation(requires cupy). -* Sinkhorn divergence[23] and entropic regularization OT from empirical data. -* Smooth optimal transport solvers(dual and semi - dual) for KL and squared L2 regularizations[17]. -* Non regularized Wasserstein barycenters[16] with LP solver(only small scale). -* Bregman projections for Wasserstein barycenter[3], convolutional barycenter[21] and unmixing[4]. -* Optimal transport for domain adaptation with group lasso regularization[5] -* Conditional gradient[6] and Generalized conditional gradient for regularized OT[7]. -* Linear OT[14] and Joint OT matrix and mapping estimation[8]. -* Wasserstein Discriminant Analysis[11](requires autograd + pymanopt). -* Gromov - Wasserstein distances and barycenters([13] and regularized[12]) -* 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]. -* JCPOT algorithm for multi - source domain adaptation with target shift[27]. -* Partial Wasserstein and Gromov - Wasserstein(exact[29] and entropic[3] formulations). - -Some demonstrations(both in Python and Jupyter Notebook format) are available in the examples folder. +* OT Network Flow solver for the linear program/ Earth Movers Distance [1]. +* Entropic regularization OT solver with Sinkhorn Knopp Algorithm [2], stabilized version [9][10] and greedy Sinkhorn [22] with optional GPU implementation (requires cupy). +* Sinkhorn divergence [23] and entropic regularization OT from empirical data. +* Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. +* Non regularized Wasserstein barycenters [16] with LP solver (only small scale). +* Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. +* Optimal transport for domain adaptation with group lasso regularization [5] +* Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. +* Linear OT [14] and Joint OT matrix and mapping estimation [8]. +* Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). +* Gromov-Wasserstein distances and barycenters ([13] and regularized [12]) +* 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]. +* JCPOT algorithm for multi-source domain adaptation with target shift [27]. +* Partial Wasserstein and Gromov-Wasserstein (exact [29] and entropic [3] formulations). + +Some demonstrations (both in Python and Jupyter Notebook format) are available in the examples folder. #### Using and citing the toolbox If you use this toolbox in your research and find it useful, please cite POT using the following bibtex reference: ``` - - @misc{flamary2017pot, - title = {POT Python Optimal Transport library}, - author = {Flamary, R{'e}mi and Courty, Nicolas}, - url = {https: // github.com / rflamary / POT}, - year = {2017} - } +title={POT Python Optimal Transport library}, +author={Flamary, R{'e}mi and Courty, Nicolas}, +url={https://github.com/rflamary/POT}, +year={2017} +} ``` ## Installation -The library has been tested on Linux, MacOSX and Windows. It requires a C + + compiler for building / installing the EMD solver and relies on the following Python modules: +The library has been tested on Linux, MacOSX and Windows. It requires a C++ compiler for building/installing the EMD solver and relies on the following Python modules: -- Numpy ( >= 1.11) -- Scipy ( >= 1.0) -- Cython ( >= 0.23) -- Matplotlib ( >= 1.5) +- Numpy (>=1.11) +- Scipy (>=1.0) +- Cython (>=0.23) +- Matplotlib (>=1.5) #### Pip installation @@ -71,33 +69,35 @@ pip install POT ``` or get the very latest version by downloading it and then running: ``` -python setup.py install - -user # for user install (no root) +python setup.py install --user # for user install (no root) ``` + #### Anaconda installation with conda-forge -If you use the Anaconda python distribution, POT is available in [conda - forge](https: // conda - forge.org). To install it and the required dependencies: +If you use the Anaconda python distribution, POT is available in [conda-forge](https://conda-forge.org). To install it and the required dependencies: ``` -conda install - c conda - forge pot +conda install -c conda-forge pot ``` #### Post installation check After a correct installation, you should be able to import the module without errors: ```python +import ot ``` Note that for easier access the module is name ot instead of pot. ### Dependencies -Some sub - modules require additional dependences which are discussed below +Some sub-modules require additional dependences which are discussed below -* **ot.dr ** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: +* **ot.dr** (Wasserstein dimensionality reduction) depends on autograd and pymanopt that can be installed with: ``` pip install pymanopt autograd ``` -* **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). +* **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 need CUDA installed and a compatible GPU. @@ -108,160 +108,160 @@ obviously you need CUDA installed and a compatible GPU. * Import the toolbox ```python +import ot ``` * Compute Wasserstein distances ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -Wd = ot.emd2(a, b, M) # exact linear program -Wd_reg = ot.sinkhorn2(a, b, M, reg) # entropic regularized OT +Wd=ot.emd2(a,b,M) # exact linear program +Wd_reg=ot.sinkhorn2(a,b,M,reg) # entropic regularized OT # if b is a matrix compute all distances to a and return a vector ``` * Compute OT matrix ```python # a,b are 1D histograms (sum to 1 and positive) # M is the ground cost matrix -T = ot.emd(a, b, M) # exact linear program -T_reg = ot.sinkhorn(a, b, M, reg) # entropic regularized OT +T=ot.emd(a,b,M) # exact linear program +T_reg=ot.sinkhorn(a,b,M,reg) # entropic regularized OT ``` * Compute Wasserstein barycenter ```python # A is a n*d matrix containing d 1D histograms # M is the ground cost matrix -ba = ot.barycenter(A, M, reg) # reg is regularization parameter +ba=ot.barycenter(A,M,reg) # reg is regularization parameter ``` + + ### Examples and Notebooks -The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http: // pot.readthedocs.io / ). +The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/). -Here is a list of the Python notebooks available [here](https: // github.com / rflamary / POT / blob / master / notebooks / ) if you want a quick look: +Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look: -* [1D optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_1D.ipynb) -* [OT Ground Loss](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https: // github.com / rflamary / POT / blob / master / notebooks / plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https: // github.com / rflamary / POT / blob / master / notebooks / plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_d2.ipynb) -* [Color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https: // github.com / rflamary / POT / blob / master / notebooks / plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https: // github.com / rflamary / POT / blob / master / notebooks / plot_WDA.ipynb) -* [Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https: // github.com / rflamary / POT / blob / master / notebooks / plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https: // github.com / rflamary / POT / blob / master / notebooks / plot_barycenter_fgw.ipynb) +* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb) +* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb) +* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb) +* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) -You can also see the notebooks with [Jupyter nbviewer](https: // nbviewer.jupyter.org / github / rflamary / POT / tree / master / notebooks / ). +You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/). ## Acknowledgements This toolbox has been created and is maintained by -* [Rémi Flamary](http: // remi.flamary.com / ) -* [Nicolas Courty](http: // people.irisa.fr / Nicolas.Courty / ) +* [Rémi Flamary](http://remi.flamary.com/) +* [Nicolas Courty](http://people.irisa.fr/Nicolas.Courty/) -The contributors to this library are +The contributors to this library are -* [Alexandre Gramfort](http: // alexandre.gramfort.net / ) -* [Laetitia Chapel](http: // people.irisa.fr / Laetitia.Chapel / ) -* [Michael Perrot](http: // perso.univ - st - etienne.fr / pem82055 / ) (Mapping estimation) -* [Léo Gautheron](https: // github.com / aje)(GPU implementation) -* [Nathalie Gayraud](https: // www.linkedin.com / in / nathalie - t - h - gayraud /?ppe=1) -* [Stanislas Chambon](https: // slasnista.github.io / ) -* [Antoine Rolet](https: // arolet.github.io / ) -* Erwan Vautier(Gromov - Wasserstein) -* [Kilian Fatras](https: // kilianfatras.github.io / ) -* [Alain Rakotomamonjy](https: // sites.google.com / site / alainrakotomamonjy / home) -* [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) +* [Alexandre Gramfort](http://alexandre.gramfort.net/) +* [Laetitia Chapel](http://people.irisa.fr/Laetitia.Chapel/) +* [Michael Perrot](http://perso.univ-st-etienne.fr/pem82055/) (Mapping estimation) +* [Léo Gautheron](https://github.com/aje) (GPU implementation) +* [Nathalie Gayraud](https://www.linkedin.com/in/nathalie-t-h-gayraud/?ppe=1) +* [Stanislas Chambon](https://slasnista.github.io/) +* [Antoine Rolet](https://arolet.github.io/) +* Erwan Vautier (Gromov-Wasserstein) +* [Kilian Fatras](https://kilianfatras.github.io/) +* [Alain Rakotomamonjy](https://sites.google.com/site/alainrakotomamonjy/home) +* [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): +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): -* [Gabriel Peyré](http: // gpeyre.github.io / ) (Wasserstein Barycenters in Matlab) -* [Nicolas Bonneel](http: // liris.cnrs.fr / ~nbonneel /) (C++ code for EMD) -* [Marco Cuturi](http: // marcocuturi.net / ) (Sinkhorn Knopp in Matlab/Cuda) +* [Gabriel Peyré](http://gpeyre.github.io/) (Wasserstein Barycenters in Matlab) +* [Nicolas Bonneel](http://liris.cnrs.fr/~nbonneel/) ( C++ code for EMD) +* [Marco Cuturi](http://marcocuturi.net/) (Sinkhorn Knopp in Matlab/Cuda) ## Contributions and code of conduct -Every contribution is welcome and should respect the[contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the[code of conduct](CODE_OF_CONDUCT.md). +Every contribution is welcome and should respect the [contribution guidelines](CONTRIBUTING.md). Each member of the project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md). ## Support You can ask questions and join the development discussion: -* On the[POT Slack channel](https: // pot - toolbox.slack.com) -* On the POT [mailing list](https: // mail.python.org / mm3 / mailman3 / lists / pot.python.org / ) +* On the [POT Slack channel](https://pot-toolbox.slack.com) +* On the POT [mailing list](https://mail.python.org/mm3/mailman3/lists/pot.python.org/) -You can also post bug reports and feature requests in Github issues. Make sure to read our[guidelines](CONTRIBUTING.md) first. +You can also post bug reports and feature requests in Github issues. Make sure to read our [guidelines](CONTRIBUTING.md) first. ## References -[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https: // people.csail.mit.edu / sparis / publi / 2011 / sigasia / Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics(TOG)(Vol. 30, No. 6, p. 158). ACM. +[1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). [Displacement interpolation using Lagrangian mass transport](https://people.csail.mit.edu/sparis/publi/2011/sigasia/Bonneel_11_Displacement_Interpolation.pdf). In ACM Transactions on Graphics (TOG) (Vol. 30, No. 6, p. 158). ACM. -[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https: // arxiv.org / pdf / 1306.0895.pdf). In Advances in Neural Information Processing Systems(pp. 2292 - 2300). +[2] Cuturi, M. (2013). [Sinkhorn distances: Lightspeed computation of optimal transport](https://arxiv.org/pdf/1306.0895.pdf). In Advances in Neural Information Processing Systems (pp. 2292-2300). -[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https: // arxiv.org / pdf / 1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111 - A1138. +[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015). [Iterative Bregman projections for regularized transportation problems](https://arxiv.org/pdf/1412.5154.pdf). SIAM Journal on Scientific Computing, 37(2), A1111-A1138. -[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https: // hal.archives - ouvertes.fr / hal - 01377236 / document), Whorkshop on Hyperspectral Image and Signal Processing: Evolution in Remote Sensing(WHISPERS), 2016. +[4] S. Nakhostin, N. Courty, R. Flamary, D. Tuia, T. Corpetti, [Supervised planetary unmixing with optimal transport](https://hal.archives-ouvertes.fr/hal-01377236/document), Whorkshop on Hyperspectral Image and Signal Processing : Evolution in Remote Sensing (WHISPERS), 2016. -[5] N. Courty -R. Flamary -D. Tuia -A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https: // arxiv.org / pdf / 1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol.PP, no.99, pp.1 - 1 +[5] N. Courty; R. Flamary; D. Tuia; A. Rakotomamonjy, [Optimal Transport for Domain Adaptation](https://arxiv.org/pdf/1507.00504.pdf), in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 -[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https: // arxiv.org / pdf / 1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853 - 1882. +[6] Ferradans, S., Papadakis, N., Peyré, G., & Aujol, J. F. (2014). [Regularized discrete optimal transport](https://arxiv.org/pdf/1307.5551.pdf). SIAM Journal on Imaging Sciences, 7(3), 1853-1882. -[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https: // arxiv.org / pdf / 1510.06567.pdf). arXiv preprint arXiv: 1510.06567. +[7] Rakotomamonjy, A., Flamary, R., & Courty, N. (2015). [Generalized conditional gradient: analysis of convergence and applications](https://arxiv.org/pdf/1510.06567.pdf). arXiv preprint arXiv:1510.06567. -[8] M. Perrot, N. Courty, R. Flamary, A. Habrard(2016), [Mapping estimation for discrete optimal transport](http: // remi.flamary.com / biblio / perrot2016mapping.pdf), Neural Information Processing Systems(NIPS). +[8] M. Perrot, N. Courty, R. Flamary, A. Habrard (2016), [Mapping estimation for discrete optimal transport](http://remi.flamary.com/biblio/perrot2016mapping.pdf), Neural Information Processing Systems (NIPS). -[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https: // arxiv.org / pdf / 1610.06519.pdf). arXiv preprint arXiv: 1610.06519. +[9] Schmitzer, B. (2016). [Stabilized Sparse Scaling Algorithms for Entropy Regularized Transport Problems](https://arxiv.org/pdf/1610.06519.pdf). arXiv preprint arXiv:1610.06519. -[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https: // arxiv.org / pdf / 1607.05816.pdf). arXiv preprint arXiv: 1607.05816. +[10] Chizat, L., Peyré, G., Schmitzer, B., & Vialard, F. X. (2016). [Scaling algorithms for unbalanced transport problems](https://arxiv.org/pdf/1607.05816.pdf). arXiv preprint arXiv:1607.05816. -[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https: // arxiv.org / pdf / 1608.08063.pdf). arXiv preprint arXiv: 1608.08063. +[11] Flamary, R., Cuturi, M., Courty, N., & Rakotomamonjy, A. (2016). [Wasserstein Discriminant Analysis](https://arxiv.org/pdf/1608.08063.pdf). arXiv preprint arXiv:1608.08063. -[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon(2016), [Gromov - Wasserstein averaging of kernel and distance matrices](http: // proceedings.mlr.press / v48 / peyre16.html) International Conference on Machine Learning(ICML). +[12] Gabriel Peyré, Marco Cuturi, and Justin Solomon (2016), [Gromov-Wasserstein averaging of kernel and distance matrices](http://proceedings.mlr.press/v48/peyre16.html) International Conference on Machine Learning (ICML). -[13] Mémoli, Facundo(2011). [Gromov–Wasserstein distances and the metric approach to object matching](https: // media.adelaide.edu.au / acvt / Publications / 2011 / 2011 - Gromov % E2 % 80 % 93Wasserstein % 20Distances % 20and % 20the % 20Metric % 20Approach % 20to % 20Object % 20Matching.pdf). Foundations of computational mathematics 11.4: 417 - 487. +[13] Mémoli, Facundo (2011). [Gromov–Wasserstein distances and the metric approach to object matching](https://media.adelaide.edu.au/acvt/Publications/2011/2011-Gromov%E2%80%93Wasserstein%20Distances%20and%20the%20Metric%20Approach%20to%20Object%20Matching.pdf). Foundations of computational mathematics 11.4 : 417-487. -[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https: // link.springer.com / article / 10.1007 / BF00934745), Journal of Optimization Theory and Applications Vol 43. +[14] Knott, M. and Smith, C. S. (1984).[On the optimal mapping of distributions](https://link.springer.com/article/10.1007/BF00934745), Journal of Optimization Theory and Applications Vol 43. -[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https: // arxiv.org / pdf / 1803.00567.pdf) . +[15] Peyré, G., & Cuturi, M. (2018). [Computational Optimal Transport](https://arxiv.org/pdf/1803.00567.pdf) . -[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https: // hal.archives - ouvertes.fr / hal - 00637399 / document). SIAM Journal on Mathematical Analysis, 43(2), 904 - 924. +[16] Agueh, M., & Carlier, G. (2011). [Barycenters in the Wasserstein space](https://hal.archives-ouvertes.fr/hal-00637399/document). SIAM Journal on Mathematical Analysis, 43(2), 904-924. -[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https: // arxiv.org / abs / 1710.06276). Proceedings of the Twenty - First International Conference on Artificial Intelligence and Statistics(AISTATS). +[17] Blondel, M., Seguy, V., & Rolet, A. (2018). [Smooth and Sparse Optimal Transport](https://arxiv.org/abs/1710.06276). Proceedings of the Twenty-First International Conference on Artificial Intelligence and Statistics (AISTATS). -[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016)[Stochastic Optimization for Large - scale Optimal Transport](https: // arxiv.org / abs / 1605.08527). Advances in Neural Information Processing Systems(2016). +[18] Genevay, A., Cuturi, M., Peyré, G. & Bach, F. (2016) [Stochastic Optimization for Large-scale Optimal Transport](https://arxiv.org/abs/1605.08527). Advances in Neural Information Processing Systems (2016). -[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A. & Blondel, M. [Large - scale Optimal Transport and Mapping Estimation](https: // arxiv.org / pdf / 1711.02283.pdf). International Conference on Learning Representation(2018) +[19] Seguy, V., Bhushan Damodaran, B., Flamary, R., Courty, N., Rolet, A.& Blondel, M. [Large-scale Optimal Transport and Mapping Estimation](https://arxiv.org/pdf/1711.02283.pdf). International Conference on Learning Representation (2018) -[20] Cuturi, M. and Doucet, A. (2014)[Fast Computation of Wasserstein Barycenters](http: // proceedings.mlr.press / v32 / cuturi14.html). International Conference in Machine Learning +[20] Cuturi, M. and Doucet, A. (2014) [Fast Computation of Wasserstein Barycenters](http://proceedings.mlr.press/v32/cuturi14.html). International Conference in Machine Learning -[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https: // dl.acm.org / citation.cfm?id=2766963). ACM Transactions on Graphics(TOG), 34(4), 66. +[21] Solomon, J., De Goes, F., Peyré, G., Cuturi, M., Butscher, A., Nguyen, A. & Guibas, L. (2015). [Convolutional wasserstein distances: Efficient optimal transportation on geometric domains](https://dl.acm.org/citation.cfm?id=2766963). ACM Transactions on Graphics (TOG), 34(4), 66. -[22] J. Altschuler, J.Weed, P. Rigollet, (2017)[Near - linear time approximation algorithms for optimal transport via Sinkhorn iteration](https: // papers.nips.cc / paper / 6792 - near - linear - time - approximation - algorithms - for-optimal - transport - via - sinkhorn - iteration.pdf), Advances in Neural Information Processing Systems(NIPS) 31 +[22] J. Altschuler, J.Weed, P. Rigollet, (2017) [Near-linear time approximation algorithms for optimal transport via Sinkhorn iteration](https://papers.nips.cc/paper/6792-near-linear-time-approximation-algorithms-for-optimal-transport-via-sinkhorn-iteration.pdf), Advances in Neural Information Processing Systems (NIPS) 31 -[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https: // arxiv.org / abs / 1706.00292), Proceedings of the Twenty - First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 +[23] Aude, G., Peyré, G., Cuturi, M., [Learning Generative Models with Sinkhorn Divergences](https://arxiv.org/abs/1706.00292), Proceedings of the Twenty-First International Conference on Artficial Intelligence and Statistics, (AISTATS) 21, 2018 -[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). +[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. (2015). [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). +[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). -[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi - source Domain Adaptation under Target Shift](http: // proceedings.mlr.press / v89 / redko19a.html), Proceedings of the Twenty - Second International Conference on Artificial Intelligence and Statistics(AISTATS) 22, 2019. +[27] Redko I., Courty N., Flamary R., Tuia D. (2019). [Optimal Transport for Multi-source Domain Adaptation under Target Shift](http://proceedings.mlr.press/v89/redko19a.html), Proceedings of the Twenty-Second International Conference on Artificial Intelligence and Statistics (AISTATS) 22, 2019. -[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge - Ampere obstacle problems](http: // www.math.toronto.edu / ~mccann / papers / annals2010.pdf), Annals of mathematics, 673 - 730. +[28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge-Ampere obstacle problems](http://www.math.toronto.edu/~mccann/papers/annals2010.pdf), Annals of mathematics, 673-730. -[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov - Wasserstein with Applications on Positive - Unlabeled Learning](https: // arxiv.org / abs / 2002.08276), arXiv preprint arXiv: 2002.08276. +[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov-Wasserstein with Applications on Positive-Unlabeled Learning](https://arxiv.org/abs/2002.08276), arXiv preprint arXiv:2002.08276. -- cgit v1.2.3 From 3409778d6f8ed2f9b7ed9977566348cec38a3dd7 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:27:32 +0200 Subject: hell --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28d2b2a..9d113bd 100644 --- a/README.md +++ b/README.md @@ -264,4 +264,4 @@ You can also post bug reports and feature requests in Github issues. Make sure t [28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge-Ampere obstacle problems](http://www.math.toronto.edu/~mccann/papers/annals2010.pdf), Annals of mathematics, 673-730. -[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov-Wasserstein with Applications on Positive-Unlabeled Learning](https://arxiv.org/abs/2002.08276), arXiv preprint arXiv:2002.08276. +[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov-Wasserstein with Applications on Positive-Unlabeled Learning](https://arxiv.org/abs/2002.08276), arXiv preprint arXiv:2002.08276. \ No newline at end of file -- cgit v1.2.3 From 1a36193c6616b8ad89fe0e0f2a5a7ab137e9d820 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:31:37 +0200 Subject: readme with laplace --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9d113bd..6b43eae 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ It provides the following solvers: * Smooth optimal transport solvers (dual and semi-dual) for KL and squared L2 regularizations [17]. * Non regularized Wasserstein barycenters [16] with LP solver (only small scale). * Bregman projections for Wasserstein barycenter [3], convolutional barycenter [21] and unmixing [4]. -* Optimal transport for domain adaptation with group lasso regularization [5] +* Optimal transport for domain adaptation with group lasso regularization and Laplacian regularization [5][30] * Conditional gradient [6] and Generalized conditional gradient for regularized OT [7]. * Linear OT [14] and Joint OT matrix and mapping estimation [8]. * Wasserstein Discriminant Analysis [11] (requires autograd + pymanopt). @@ -184,6 +184,7 @@ The contributors to this library are * [Hicham Janati](https://hichamjanati.github.io/) (Unbalanced OT) * [Romain Tavenard](https://rtavenar.github.io/) (1d Wasserstein) * [Mokhtar Z. Alaya](http://mzalaya.github.io/) (Screenkhorn) +* [Ievgen Redko](https://ievred.github.io/) 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): @@ -264,4 +265,6 @@ You can also post bug reports and feature requests in Github issues. Make sure t [28] Caffarelli, L. A., McCann, R. J. (2020). [Free boundaries in optimal transport and Monge-Ampere obstacle problems](http://www.math.toronto.edu/~mccann/papers/annals2010.pdf), Annals of mathematics, 673-730. -[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov-Wasserstein with Applications on Positive-Unlabeled Learning](https://arxiv.org/abs/2002.08276), arXiv preprint arXiv:2002.08276. \ No newline at end of file +[29] Chapel, L., Alaya, M., Gasso, G. (2019). [Partial Gromov-Wasserstein with Applications on Positive-Unlabeled Learning](https://arxiv.org/abs/2002.08276), arXiv preprint arXiv:2002.08276. + +[30] Flamary R., Courty N., Tuia D., Rakotomamonjy A. (2014). [Optimal transport with Laplacian regularization: Applications to domain adaptation and shape matching](https://remi.flamary.com/biblio/flamary2014optlaplace.pdf), NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. -- cgit v1.2.3 From fd115a538deb8fa9dcf3169fcfa6b85aebd36b07 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 13:55:45 +0200 Subject: sim+sim param fixed --- ot/da.py | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/ot/da.py b/ot/da.py index 8e26e31..300af30 100644 --- a/ot/da.py +++ b/ot/da.py @@ -748,7 +748,7 @@ def OT_mapping_linear(xs, xt, reg=1e-6, ws=None, return A, b -def emd_laplace(a, b, xs, xt, M, reg, eta, alpha, +def emd_laplace(a, b, xs, xt, M, sim, sim_param, reg, eta, alpha, numItermax, stopThr, numInnerItermax, stopInnerThr, log=False, verbose=False, **kwargs): r"""Solve the optimal transport problem (OT) with Laplacian regularization @@ -785,6 +785,11 @@ def emd_laplace(a, b, xs, xt, M, reg, eta, alpha, samples in the target domain M : np.ndarray (ns,nt) loss matrix + sim : string, optional + Type of similarity ('knn' or 'gauss') used to construct the Laplacian. + sim_param : int or float, optional + Parameter (number of the nearest neighbors for sim='knn' + or bandwidth for sim='gauss' used to compute the Laplacian. reg : string Type of Laplacian regularization eta : float @@ -803,11 +808,6 @@ def emd_laplace(a, b, xs, xt, M, reg, eta, alpha, Print information along iterations log : bool, optional record log if True - kwargs : dict - Dictionary with attributes 'sim' ('knn' or 'gauss') and - 'param' (int, float or None) for similarity type and its parameter to be used. - If 'param' is None, it is computed as mean pairwise Euclidean distance over the data set - or set to 3 when sim is 'gauss' or 'knn', respectively. Returns ------- @@ -824,7 +824,7 @@ def emd_laplace(a, b, xs, xt, M, reg, eta, alpha, "Optimal Transport for Domain Adaptation," in IEEE Transactions on Pattern Analysis and Machine Intelligence , vol.PP, no.99, pp.1-1 - .. [28] R. Flamary, N. Courty, D. Tuia, A. Rakotomamonjy, + .. [30] R. Flamary, N. Courty, D. Tuia, A. Rakotomamonjy, "Optimal transport with Laplacian regularization: Applications to domain adaptation and shape matching," in NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. @@ -834,28 +834,28 @@ def emd_laplace(a, b, xs, xt, M, reg, eta, alpha, ot.optim.cg : General regularized OT """ - if not isinstance(kwargs['param'], (int, float, type(None))): + if not isinstance(sim_param, (int, float, type(None))): raise ValueError( - 'Similarity parameter should be an int or a float. Got {type} instead.'.format(type=type(kwargs['param']))) + 'Similarity parameter should be an int or a float. Got {type} instead.'.format(type=type(sim_param).__name__)) - if kwargs['sim'] == 'gauss': - if kwargs['param'] is None: - kwargs['param'] = 1 / (2 * (np.mean(dist(xs, xs, 'sqeuclidean')) ** 2)) - sS = kernel(xs, xs, method=kwargs['sim'], sigma=kwargs['param']) - sT = kernel(xt, xt, method=kwargs['sim'], sigma=kwargs['param']) + if sim == 'gauss': + if sim_param is None: + sim_param = 1 / (2 * (np.mean(dist(xs, xs, 'sqeuclidean')) ** 2)) + sS = kernel(xs, xs, method=sim, sigma=sim_param) + sT = kernel(xt, xt, method=sim, sigma=sim_param) - elif kwargs['sim'] == 'knn': - if kwargs['param'] is None: - kwargs['param'] = 3 + elif sim == 'knn': + if sim_param is None: + sim_param = 3 from sklearn.neighbors import kneighbors_graph - sS = kneighbors_graph(X=xs, n_neighbors=int(kwargs['param'])).toarray() + sS = kneighbors_graph(X=xs, n_neighbors=int(sim_param)).toarray() sS = (sS + sS.T) / 2 - sT = kneighbors_graph(xt, n_neighbors=int(kwargs['param'])).toarray() + sT = kneighbors_graph(xt, n_neighbors=int(sim_param)).toarray() sT = (sT + sT.T) / 2 else: - raise ValueError('Unknown similarity type {sim}. Currently supported similarity types are "knn" and "gauss".'.format(sim=kwargs['sim'])) + raise ValueError('Unknown similarity type {sim}. Currently supported similarity types are "knn" and "gauss".'.format(sim=sim)) lS = laplacian(sS) lT = laplacian(sT) @@ -1729,9 +1729,10 @@ class EMDLaplaceTransport(BaseTransport): can occur with large metric values. similarity : string, optional (default="knn") The similarity to use either knn or gaussian - similarity_param : int or float, optional (default=3) + similarity_param : int or float, optional (default=None) Parameter for the similarity: number of nearest neighbors or bandwidth - if similarity="knn" or "gaussian", respectively. + if similarity="knn" or "gaussian", respectively. If None is provided, + it is set to 3 or the average pairwise squared Euclidean distance, respectively. max_iter : int, optional (default=100) Max number of BCD iterations tol : float, optional (default=1e-5) @@ -1813,14 +1814,10 @@ class EMDLaplaceTransport(BaseTransport): super(EMDLaplaceTransport, self).fit(Xs, ys, Xt, yt) - kwargs = dict() - kwargs["sim"] = self.similarity - kwargs["param"] = self.sim_param - returned_ = emd_laplace(a=self.mu_s, b=self.mu_t, xs=self.xs_, - xt=self.xt_, M=self.cost_, reg=self.reg, eta=self.reg_lap, alpha=self.reg_src, + xt=self.xt_, M=self.cost_, sim=self.similarity, sim_param=self.sim_param, reg=self.reg, eta=self.reg_lap, alpha=self.reg_src, numItermax=self.max_iter, stopThr=self.tol, numInnerItermax=self.max_inner_iter, - stopInnerThr=self.inner_tol, log=self.log, verbose=self.verbose, **kwargs) + stopInnerThr=self.inner_tol, log=self.log, verbose=self.verbose) # coupling estimation if self.log: -- cgit v1.2.3 From 36b2e92d9ad5148208cc1bec9bc9133999bcdb1c Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 14:04:32 +0200 Subject: added defaults for emd_laplace --- ot/da.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ot/da.py b/ot/da.py index 300af30..e615993 100644 --- a/ot/da.py +++ b/ot/da.py @@ -748,9 +748,9 @@ def OT_mapping_linear(xs, xt, reg=1e-6, ws=None, return A, b -def emd_laplace(a, b, xs, xt, M, sim, sim_param, reg, eta, alpha, - numItermax, stopThr, numInnerItermax, - stopInnerThr, log=False, verbose=False, **kwargs): +def emd_laplace(a, b, xs, xt, M, sim='knn', sim_param=None, reg='pos', eta=1, alpha=.5, + numItermax=100, stopThr=1e-9, numInnerItermax=100000, + stopInnerThr=1e-9, log=False, verbose=False): r"""Solve the optimal transport problem (OT) with Laplacian regularization .. math:: @@ -1765,15 +1765,14 @@ class EMDLaplaceTransport(BaseTransport): in NIPS Workshop on Optimal Transport and Machine Learning OTML, 2014. """ - def __init__(self, reg_type='pos', reg_lap=1., reg_src=1., alpha=0.5, - metric="sqeuclidean", norm=None, similarity="knn", similarity_param=None, max_iter=100, tol=1e-9, + def __init__(self, reg_type='pos', reg_lap=1., reg_src=1., metric="sqeuclidean", + norm=None, similarity="knn", similarity_param=None, max_iter=100, tol=1e-9, max_inner_iter=100000, inner_tol=1e-9, log=False, verbose=False, distribution_estimation=distribution_estimation_uniform, out_of_sample_map='ferradans'): self.reg = reg_type self.reg_lap = reg_lap self.reg_src = reg_src - self.alpha = alpha self.metric = metric self.norm = norm self.similarity = similarity @@ -1815,8 +1814,8 @@ class EMDLaplaceTransport(BaseTransport): super(EMDLaplaceTransport, self).fit(Xs, ys, Xt, yt) returned_ = emd_laplace(a=self.mu_s, b=self.mu_t, xs=self.xs_, - xt=self.xt_, M=self.cost_, sim=self.similarity, sim_param=self.sim_param, reg=self.reg, eta=self.reg_lap, alpha=self.reg_src, - numItermax=self.max_iter, stopThr=self.tol, numInnerItermax=self.max_inner_iter, + xt=self.xt_, M=self.cost_, sim=self.similarity, sim_param=self.sim_param, reg=self.reg, eta=self.reg_lap, + alpha=self.reg_src, numItermax=self.max_iter, stopThr=self.tol, numInnerItermax=self.max_inner_iter, stopInnerThr=self.inner_tol, log=self.log, verbose=self.verbose) # coupling estimation -- cgit v1.2.3 From b706bad0653407b14a8b79a0315aed0ced29e833 Mon Sep 17 00:00:00 2001 From: Rémi Flamary Date: Mon, 20 Apr 2020 14:11:22 +0200 Subject: Change rflamary to PythonOT in Readme --- README.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 6b43eae..44d35a7 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ [![PyPI version](https://badge.fury.io/py/POT.svg)](https://badge.fury.io/py/POT) [![Anaconda Cloud](https://anaconda.org/conda-forge/pot/badges/version.svg)](https://anaconda.org/conda-forge/pot) -[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/rflamary/POT) +[![Build Status](https://travis-ci.org/rflamary/POT.svg?branch=master)](https://travis-ci.org/PythonOT/POT) [![Documentation Status](https://readthedocs.org/projects/pot/badge/?version=latest)](http://pot.readthedocs.io/en/latest/?badge=latest) [![Downloads](https://pepy.tech/badge/pot)](https://pepy.tech/project/pot) [![Anaconda downloads](https://anaconda.org/conda-forge/pot/badges/downloads.svg)](https://anaconda.org/conda-forge/pot) -[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/rflamary/POT/blob/master/LICENSE) +[![License](https://anaconda.org/conda-forge/pot/badges/license.svg)](https://github.com/PythonOT/POT/blob/master/LICENSE) @@ -140,26 +140,26 @@ ba=ot.barycenter(A,M,reg) # reg is regularization parameter The examples folder contain several examples and use case for the library. The full documentation is available on [Readthedocs](http://pot.readthedocs.io/). -Here is a list of the Python notebooks available [here](https://github.com/rflamary/POT/blob/master/notebooks/) if you want a quick look: +Here is a list of the Python notebooks available [here](https://github.com/PythonOT/POT/blob/master/notebooks/) if you want a quick look: -* [1D optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_1D.ipynb) -* [OT Ground Loss](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) -* [Multiple EMD computation](https://github.com/rflamary/POT/blob/master/notebooks/plot_compute_emd.ipynb) -* [2D optimal transport on empirical distributions](https://github.com/rflamary/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) -* [1D Wasserstein barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) -* [OT with user provided regularization](https://github.com/rflamary/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) -* [Domain adaptation with optimal transport](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_d2.ipynb) -* [Color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_color_images.ipynb) -* [OT mapping estimation for domain adaptation](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping.ipynb) -* [OT mapping estimation for color transfer in images](https://github.com/rflamary/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) -* [Wasserstein Discriminant Analysis](https://github.com/rflamary/POT/blob/master/notebooks/plot_WDA.ipynb) -* [Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov.ipynb) -* [Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) -* [Fused Gromov Wasserstein](https://github.com/rflamary/POT/blob/master/notebooks/plot_fgw.ipynb) -* [Fused Gromov Wasserstein Barycenter](https://github.com/rflamary/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) +* [1D optimal transport](https://github.com/PythonOT/POT/blob/master/notebooks/plot_OT_1D.ipynb) +* [OT Ground Loss](https://github.com/PythonOT/POT/blob/master/notebooks/plot_OT_L1_vs_L2.ipynb) +* [Multiple EMD computation](https://github.com/PythonOT/POT/blob/master/notebooks/plot_compute_emd.ipynb) +* [2D optimal transport on empirical distributions](https://github.com/PythonOT/POT/blob/master/notebooks/plot_OT_2D_samples.ipynb) +* [1D Wasserstein barycenter](https://github.com/PythonOT/POT/blob/master/notebooks/plot_barycenter_1D.ipynb) +* [OT with user provided regularization](https://github.com/PythonOT/POT/blob/master/notebooks/plot_optim_OTreg.ipynb) +* [Domain adaptation with optimal transport](https://github.com/PythonOT/POT/blob/master/notebooks/plot_otda_d2.ipynb) +* [Color transfer in images](https://github.com/PythonOT/POT/blob/master/notebooks/plot_otda_color_images.ipynb) +* [OT mapping estimation for domain adaptation](https://github.com/PythonOT/POT/blob/master/notebooks/plot_otda_mapping.ipynb) +* [OT mapping estimation for color transfer in images](https://github.com/PythonOT/POT/blob/master/notebooks/plot_otda_mapping_colors_images.ipynb) +* [Wasserstein Discriminant Analysis](https://github.com/PythonOT/POT/blob/master/notebooks/plot_WDA.ipynb) +* [Gromov Wasserstein](https://github.com/PythonOT/POT/blob/master/notebooks/plot_gromov.ipynb) +* [Gromov Wasserstein Barycenter](https://github.com/PythonOT/POT/blob/master/notebooks/plot_gromov_barycenter.ipynb) +* [Fused Gromov Wasserstein](https://github.com/PythonOT/POT/blob/master/notebooks/plot_fgw.ipynb) +* [Fused Gromov Wasserstein Barycenter](https://github.com/PythonOT/POT/blob/master/notebooks/plot_barycenter_fgw.ipynb) -You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/rflamary/POT/tree/master/notebooks/). +You can also see the notebooks with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/PythonOT/POT/tree/master/notebooks/). ## Acknowledgements -- cgit v1.2.3 From 470fce2b6ae01134e3e2fb7a27d9966fd776dae8 Mon Sep 17 00:00:00 2001 From: ievred Date: Mon, 20 Apr 2020 14:12:49 +0200 Subject: added defaults for emd_laplace --- ot/da.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ot/da.py b/ot/da.py index e615993..6249f08 100644 --- a/ot/da.py +++ b/ot/da.py @@ -789,7 +789,7 @@ def emd_laplace(a, b, xs, xt, M, sim='knn', sim_param=None, reg='pos', eta=1, al Type of similarity ('knn' or 'gauss') used to construct the Laplacian. sim_param : int or float, optional Parameter (number of the nearest neighbors for sim='knn' - or bandwidth for sim='gauss' used to compute the Laplacian. + or bandwidth for sim='gauss') used to compute the Laplacian. reg : string Type of Laplacian regularization eta : float -- cgit v1.2.3