{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Quickstart Guide\n\nQuickstart guide to the POT toolbox.\n\nFor better readability, only the use of POT is provided and the plotting code\nwith matplotlib is hidden (but is available in the source file of the example).\n\n
We use here the unified API of POT which is more flexible and allows to solve a wider range of problems with just a few functions. The classical API is still available (the unified API\n one is a convenient wrapper around the classical one) and we provide pointers to the\n classical API when needed.
The examples above use the unified API of POT. The classic API is still available\n and and OT plan and loss can be computed with the :func:`ot.emd` and\n the :func:`ot.emd2` functions as below:\n\n```python\nP = ot.emd(a, b, C)\nloss = ot.emd2(a, b, C) # same as np.sum(P*C) but differentiable wrt a/b
The examples above use the unified API of POT. The classic API is still available\n and and the entropic OT plan and loss can be computed with the\n :func:`ot.sinkhorn` # and :func:`ot.sinkhorn2` functions as below:\n\n```python\nGs = ot.sinkhorn(a, b, C, reg=1e-1)\nloss_sink = ot.sinkhorn2(a, b, C, reg=1e-1)\n```\n For quadratic regularization, the :func:`ot.smooth.smooth_ot_dual` function\n can be used to compute the solution of the regularized OT problem. For\n user-defined regularization, the :func:`ot.optim.cg` function can be used\n to solve the regularized OT problem with Conditional Gradient algorithm.
Solving the unbalanced OT problem with the classic API can be done with the\n :func:`ot.unbalanced.sinkhorn_unbalanced` function as below:\n\n```python\nG_unb_kl = ot.unbalanced.sinkhorn_unbalanced(a, b, C, eps=reg, alpha=unbalanced)
The Gromov-Wasserstein problem can be solved with the classic API using the\n :func:`ot.gromov.gromov_wasserstein` function and the Entropic\n Gromov-Wasserstein problem can be solved with the\n :func:`ot.gromov.entropic_gromov_wasserstein` function.\n\n```python\nP_gw = ot.gromov.gromov_wasserstein(C1, C2, a, b)\nP_egw = ot.gromov.entropic_gromov_wasserstein(C1, C2, a, b, epsilon=reg)\n\nloss_gw = ot.gromov.gromov_wasserstein2(C1, C2, a, b)\nloss_egw = ot.gromov.entropic_gromov_wasserstein2(C1, C2, a, b, epsilon=reg)
The Fused Gromov-Wasserstein problem can be solved with the classic API using\n the :func:`ot.gromov.fused_gromov_wasserstein` function and the Entropic\n Fused Gromov-Wasserstein problem can be solved with the\n :func:`ot.gromov.entropic_fused_gromov_wasserstein` function.\n\n```python\nP_fgw = ot.gromov.fused_gromov_wasserstein(C1, C2, M, a, b, alpha=0.1)\nP_efgw = ot.gromov.entropic_fused_gromov_wasserstein(C1, C2, M, a, b, alpha=0.1, epsilon=reg)\n\nloss_fgw = ot.gromov.fused_gromov_wasserstein2(C1, C2, M, a, b, alpha=0.1)\nloss_efgw = ot.gromov.entropic_fused_gromov_wasserstein2(C1, C2, M, a, b, alpha=0.1, epsilon=reg)
The lazy Sinkhorn algorithm can be found in the classic API with the\n :func:`ot.bregman.empirical_sinkhorn` function with parameter\n :code:`lazy=True`. Similarly the geoloss implementation is available\n with the :func:`ot.bregman.empirical_sinkhorn2_geomloss`.
The factored OT problem can be solved with the classic API using the\n :func:`ot.factored.factored_optimal_transport` function and the low rank\n OT problem can be solved with the :func:`ot.lowrank.lowrank_sinkhorn` function.
The Gaussian Wasserstein problem can be solved with the classic API using the\n :func:`ot.gaussian.empirical_bures_wasserstein_distance` function.