summaryrefslogtreecommitdiff
path: root/ot/utils.py
AgeCommit message (Collapse)Author
2023-05-10[FIX] Refactor the function `utils.cost_normalization` to work with multiple ↵Francisco Muñoz
backends (#472) * [FEAT] Add the 'median' method to the backend base class and implements this method in the Numpy, Pytorch, Jax and Cupy backends * [TEST] Modify the 'cost_normalization' test to multiple backends * [REFACTOR] Refactor the 'utils.cost_normalization' function for multiple backends * [TEST] Update backend tests for method 'median' * [DEBUG] Fix the error in the test in the 'median' method with PyTorch backend * [TEST] Add the edge case where the 'median' method is not yet implemented in the Tensorflow backend. * [FEAT] Implement the 'median' method in the Tensorflow backend using Numpy * [DEBUG] For compatibility reasons, the median method in the Pytorch backend change using numpy * [DEBUG] The 'median' method checks the Pytorch version to decide whether to use torch.quantile or numpy * Add changes to RELEASES.md --------- Co-authored-by: Rémi Flamary <remi.flamary@gmail.com>
2023-04-25[FEAT] add the sparsity-constrained optimal transport funtionality and ↵Tianlin Liu
example (#459) * add sparsity-constrained ot funtionality and example * correct typos; add projection_sparse_simplex * add gradcheck; merge ot.sparse into ot.smooth. * reuse existing ot.smooth functions with a new 'sparsity_constrained' reg_type * address pep8 error * add backends for * update releases --------- Co-authored-by: Rémi Flamary <remi.flamary@gmail.com>
2023-02-23[WIP] Wasserstein distance on the circle and Spherical Sliced-Wasserstein (#434)Clément Bonet
* W circle + SSW * Tests + Example SSW_1 * Example Wasserstein Circle + Tests * Wasserstein on the circle wrt Unif * Example SSW unif * pep8 * np.linalg.qr for numpy < 1.22 by batch + add python3.11 to tests * np qr * rm test python 3.11 * update names, tests, backend transpose * Comment error batchs * semidiscrete_wasserstein2_unif_circle example * torch permute method instead of torch.permute for previous versions * update comments and doc * doc wasserstein circle model as [0,1[ * Added ot.utils.get_coordinate_circle to get coordinates on the circle in turn
2022-12-15[MRG] New API for OT solver (with pre-computed ground cost matrix) (#388)Rémi Flamary
* new API for OT solver * use itertools for product of parameters * add tests for result class * add tests for result class * add tests for result class last time? * add sinkhorn * make partial OT bckend compatible * add TV as unbalanced flavor * better tests * make smoth backend compatible and add l2 tregularizatio to solve * add reularizedd unbalanced * add test for more complex attibutes * add test for more complex attibutes * add generic unbalaned solver and implement it for ot.solve * add entropy to possible regularization * star of documentation for ot.solv * weird new pep8 * documenttaion for function ot.solve done * pep8 * Update ot/solvers.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * update release file * Apply suggestions from code review Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * add test NotImplemented * pep8 * pep8gcmp pep8! * compute kl in backend * debug tensorflow kl backend Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org>
2022-09-27[MRG] Crash when computing weightless Hamming distance & Doc build (#402)Nathan Cassereau
* Bug solve * Releases.md updated * pep8 * attempt to solve docs building bug * releases.md
2022-05-16[MRG] dist: check metric is a string before calling a str method (#379)Zachary Kurtz
2022-03-24[MRG] Domain adaptation and unbalanced solvers with backend support (#343)Nathan Cassereau
* First draft * Add matrix inverse and square root to backend * Eigen decomposition for older versions of pytorch (1.8.1 and older) * Corrected eigen decomposition for pytorch 1.8.1 and older * Spectral theorem is a thing * Optimization * small optimization * More functions converted * pep8 * remove a warning and prepare torch meshgrid for future torch release (which will change default indexing) * dots and pep8 * Meshgrid corrected for older version and prepared for future versions changes * New backend functions * Base transport * LinearTransport * All transport classes + pep8 * PR added to release file * Jcpot barycenter test * unbalanced with backend * pep8 * bug solve * test of domain adaptation with backends * solve bug for tic toc & macos * solving scipy deprecation warning * solving scipy deprecation warning attempt2 * solving scipy deprecation warning attempt3 * A warning is triggered when a float->int conversion is detected * bug solve * docs * release file updated * Better handling of float->int conversion in EMD * Corrected test for is_floating_point * docs * release file updated * cupy does not allow implicit cast * fromnumpy * added test * test da tf jax * test unbalanced with no provided histogram * using type_as argument in unif function correctly * pep8 * transport plan cast in emd changed behaviour, now trying to cast as histogram's dtype, defaulting to cost matrix Co-authored-by: Rémi Flamary <remi.flamary@gmail.com>
2022-02-02[MRG] Add weak OT solver (#341)Rémi Flamary
* add info in release file * update tests * pep8 * add weak OT example * update plot in doc * correction ewample with empirical sinkhorn * better thumbnail * comment from review * update documenation
2021-11-08[MRG] Distance calculation bug solve (#306)Nathan Cassereau
* solve bug * Weights & docs * tests for dist * test dist * pep8
2021-11-03[MRG] Docs updates (#298)ncassereau-idris
* bregman docs * sliced docs * docs partial * unbalanced docs * stochastic docs * plot docs * datasets docs * utils docs * dr docs * dr docs corrected * smooth docs * docs da * pep8 * docs gromov * more space after min and argmin * docs lp * bregman docs * bregman docs mistake corrected * pep8 Co-authored-by: Rémi Flamary <remi.flamary@gmail.com>
2021-10-27[WIP] Sinkhorn in log space (#290)Rémi Flamary
* adda sinkhorn log and working sinkhorn2 function * more tests pass * more tests pass * it works but not by default yet * remove warningd * update circleci doc * update circleci doc * new sinkhorn implemeted but not by default * better * doctest pass * test doctest * new test utils * remove pep8 errors * remove pep8 errors * doc new implementtaion with log * test sinkhorn 2 * doc for log implementation
2021-09-29[MRG] OpenMP support (#260)kguerda-idris
* Added : OpenMP support Restored : Epsilon and Debug mode Replaced : parmap => multiprocessing is now replace by multithreading * Commit clean up * Number of CPUs correctly calculated on SLURM clusters * Corrected number of processes for cluster slurm * Mistake corrected * parmap is now deprecated * Now a different solver is used depending on the requested number of threads * Tiny mistake corrected * Folders are now in the ot library instead of at the root * Helpers is now correctly placed * Attempt to make compilation work smoothly * OS compatible path * NumThreads now defaults to 1 * Better flags * Mistake corrected in case of OpenMP unavailability * Revert OpenMP flags modification, which do not compile on Windows * Test helper functions * Helpers comments * Documentation update * File title corrected * Warning no longer using print * Last attempt for macos compilation * pls work * atempt * solving a type error * TypeError OpenMP * Compilation finally working on Windows * Bug solve, number of threads now correctly selected * 64 bits solver to avoid overflows for bigger problems * 64 bits EMD corrected Co-authored-by: kguerda-idris <ssos023@jean-zay3.idris.fr> Co-authored-by: ncassereau-idris <84033440+ncassereau-idris@users.noreply.github.com> Co-authored-by: ncassereau <nathan.cassereau@idris.fr> Co-authored-by: Rémi Flamary <remi.flamary@gmail.com>
2021-06-01[MRG] POT numpy/torch/jax backends (#249)Rémi Flamary
* add numpy and torch backends * stat sets on functions * proper import * install recent torch on windows * install recent torch on windows * now testing all functions in backedn * add jax backedn * clenaup windowds * proper convert for jax backedn * pep8 * try again windows tests * test jax conversion * try proper widows tests * emd fuction ses backedn * better test partial OT * proper tests to_numpy and teplate Backend * pep8 * pep8 x2 * feaking sinkhorn works with torch * sinkhorn2 compatible * working ot.emd2 * important detach * it should work * jax autodiff emd * pep8 * no tast same for jax * new independat tests per backedn * freaking pep8 * add tests for gradients * deprecate ot.gpu * worging dist function * working dist * dist done in backedn * not in * remove indexing * change accuacy for jax * first pull backend * projection simplex * projection simplex * projection simplex * projection simplex no ci * projection simplex no ci * projection simplex no ci * pep8 * add backedn discusion to quickstart guide * projection simplex no ci * projection simplex no ci * projection simplex no ci * pep8 + better doc * proper links * corect doctest * big debug documentation * doctest again * doctest again bis * doctest again ter (last one or i kill myself) * backend test + doc proj simplex * correction test_utils * correction test_utils * correction cumsum * correction flip * correction flip v2 * more debug * more debug * more debug + pep8 * pep8 * argh * proj_simplex * backedn works for sort * proj simplex * jax sucks * update doc * Update test/test_utils.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update docs/source/quickstart.rst Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update docs/source/quickstart.rst Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update docs/source/quickstart.rst Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update docs/source/readme.rst Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update test/test_utils.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update ot/utils.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update docs/source/readme.rst Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update ot/lp/__init__.py Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> * begin comment alex * comment alex part 2 * optimize test gromov * proj_simplex on vectors * add awesome gradient decsnt example on the weights * pep98 of course * proof read example by alex * pep8 again * encoding oos in translation * correct legend Co-authored-by: Nicolas Courty <ncourty@irisa.fr> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org>
2021-04-15[MRG] Add new python versions for tests (also macos and windows) (#237)Rémi Flamary
* update python versions and add macosx bigsur * add versions macosx * remove big sur and add 3.7 in macos * disable paramell on macosx * remove double run of tests that was running both on push and pr
2020-05-19[MRG] Codecov options + remove 2.7 (#178)Ayush Karnawat
* cleanup setup * Ignore files in codecov * Remove externals module * change name to compile_args * bye py2.7 (you will be missed) * glob to ignore folders
2020-04-15Merge branch 'master' into laplace_daIevgen Redko
2020-04-08added label normalization to utilsievred
2020-04-08remove laplacianievred
2020-04-03autopep+remove sinkhorn+add simtypeievred
2020-04-03v2 laplace emd sinkhornievred
2019-09-09merge new unbalancedRémi Flamary
2019-08-12Attempting to fix docstylengayraud
2019-08-12Attempting to fix docstylengayraud
2019-08-12fixes for travis, added test, minor nitsngayraud
2019-08-12Added Unbalaced transport to domain adaptation methods. Corrected small bug ↵ngayraud
related to warnings in unbalaced.py . Added an error message when user wants to normalize with other than expected cost normalization functions.
2019-07-09moreAlexandre Gramfort
2019-07-05cleanup parmap on windowsRémi Flamary
2019-07-03doc in modulesRémi Flamary
2019-07-01Fixed doctestsRomain Tavenard
2019-06-04changes forgotten comentstvayer
2018-07-16Add comment & fix flake8 errorLeoGautheron
2018-07-16Remove dependency sklearnLeoGautheron
2018-07-11Speed-up SinkhornLeoGautheron
Speed-up in 3 places: - the computation of pairwise distance is faster with sklearn.metrics.pairwise.euclidean_distances - faster computation of K = np.exp(-M / reg) - faster computation of the error every 10 iterations Example with this little script: import time import numpy as np import ot rng = np.random.RandomState(0) transport = ot.da.SinkhornTransport() time1 = time.time() Xs, ys, Xt = rng.randn(10000, 100), rng.randint(0, 2, size=10000), rng.randn(10000, 100) transport.fit(Xs=Xs, Xt=Xt) time2 = time.time() print("OT Computation Time {:6.2f} sec".format(time2-time1)) transport = ot.da.SinkhornLpl1Transport() transport.fit(Xs=Xs, ys=ys, Xt=Xt) time3 = time.time() print("OT LpL1 Computation Time {:6.2f} sec".format(time3-time2)) Before OT Computation Time 19.93 sec OT LpL1 Computation Time 133.43 sec After OT Computation Time 7.55 sec OT LpL1 Computation Time 82.25 sec
2018-05-29add check_random_state in utilsRémi Flamary
2018-03-21add externals for function signatureRémi Flamary
2018-03-21add linear mapping test + autopep8Rémi Flamary
2018-02-16better pep8 but not solvedRémi Flamary
2017-08-30Move normalize function in utils.pyaje
2017-08-28check input parameters with helper functionsSlasnista
2017-08-28move no da objects into utils.pySlasnista
2017-07-26add license and authors on all modulesRémi Flamary
2017-07-20pep8Alexandre Gramfort
2017-07-20pep8Alexandre Gramfort
2017-06-20add clean zeros function for sparse distributionsRémi Flamary
2017-06-09add doc and correct encodingRémi Flamary
2017-03-14add emd2+ multiprocRémi Flamary
2017-01-05add tic() and toc() functions for easy coarse timingRémi Flamary
2016-11-04add mapping estimation with kernels works!Rémi Flamary
2016-11-03add mapping estimation (still debugging)Rémi Flamary
2016-10-28doc plot.pyRémi Flamary