:orphan:

====================
Gallery of examples
====================

These self-contained examples showcase the features of the :mod:`geomloss` module.



.. raw:: html

    <div class="sphx-glr-thumbnails">


.. raw:: html

    </div>

Kernel vs. Hausdorff vs. Sinkhorn 
--------------------------------------

See the difference between
our **kernel**, **hausdorff** and **sinkhorn**
loss functions:



.. raw:: html

    <div class="sphx-glr-thumbnails">


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s showcase the properties of kernel MMDs, Hausdorff and Sinkhorn divergences on a simple to...">

.. only:: html

  .. image:: /_auto_examples/comparisons/images/thumb/sphx_glr_plot_gradient_flows_1D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_comparisons_plot_gradient_flows_1D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Gradient flows in 1D</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s showcase the properties of kernel MMDs, Hausdorff and Sinkhorn divergences on a simple to...">

.. only:: html

  .. image:: /_auto_examples/comparisons/images/thumb/sphx_glr_plot_gradient_flows_2D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_comparisons_plot_gradient_flows_2D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Gradient flows in 2D</div>
    </div>


.. raw:: html

    </div>


The multiscale Sinkhorn algorithm
-------------------------------------

**Outperform** the baseline Auction and Sinkhorn algorithms
by a factor **x50-100** with adaptive coarse-to-fine strategies:


.. raw:: html

    <div class="sphx-glr-thumbnails">


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Dating back to the work of Schrödinger  - see e.g. (Léonard, 2013) for a modern review - entrop...">

.. only:: html

  .. image:: /_auto_examples/sinkhorn_multiscale/images/thumb/sphx_glr_plot_epsilon_scaling_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_sinkhorn_multiscale_plot_epsilon_scaling.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">1) Blur parameter, scaling strategy</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In the previous notebook, we&#x27;ve seen that simulated annealing could be used to define efficient...">

.. only:: html

  .. image:: /_auto_examples/sinkhorn_multiscale/images/thumb/sphx_glr_plot_kernel_truncation_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_sinkhorn_multiscale_plot_kernel_truncation.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">2) Kernel truncation, log-linear runtimes</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s use a custom clustering scheme to generalize the multiscale Sinkhorn algorithm to high-di...">

.. only:: html

  .. image:: /_auto_examples/sinkhorn_multiscale/images/thumb/sphx_glr_plot_optimal_transport_cluster_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_sinkhorn_multiscale_plot_optimal_transport_cluster.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">3) Optimal Transport in high dimension</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Sinkhorn divergences rely on a simple idea: by blurring the transport plan through the addition...">

.. only:: html

  .. image:: /_auto_examples/sinkhorn_multiscale/images/thumb/sphx_glr_plot_transport_blur_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_sinkhorn_multiscale_plot_transport_blur.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">4) Sinkhorn vs. blurred Wasserstein distances</div>
    </div>


.. raw:: html

    </div>

Optimal Transport
----------------------

Use the
**sinkhorn** loss as an affordable, drop-in replacement
for the Wasserstein distance:


.. raw:: html

    <div class="sphx-glr-thumbnails">


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Optimization routines">

.. only:: html

  .. image:: /_auto_examples/optimal_transport/images/thumb/sphx_glr_model_fitting_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_optimal_transport_model_fitting.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Optimization routines</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="N.B.: I am currently very busy writing my PhD thesis. Comments will come soon!">

.. only:: html

  .. image:: /_auto_examples/optimal_transport/images/thumb/sphx_glr_plot_interpolation_3D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_optimal_transport_plot_interpolation_3D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Creating a fancy interpolation video between 3D meshes.</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s use the gradient of the Sinkhorn divergence to compute an Optimal Transport map.">

.. only:: html

  .. image:: /_auto_examples/optimal_transport/images/thumb/sphx_glr_plot_optimal_transport_2D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_optimal_transport_plot_optimal_transport_2D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Optimal Transport in 2D</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s use the gradient of the Sinkhorn divergence to change the color palette of an image.">

.. only:: html

  .. image:: /_auto_examples/optimal_transport/images/thumb/sphx_glr_plot_optimal_transport_color_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_optimal_transport_plot_optimal_transport_color.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Color transfer with Optimal Transport</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s use a regularized Optimal Transport plan to transfer labels from one point cloud to anoth...">

.. only:: html

  .. image:: /_auto_examples/optimal_transport/images/thumb/sphx_glr_plot_optimal_transport_labels_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_optimal_transport_plot_optimal_transport_labels.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Label transfer with Optimal Transport</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s compute Wasserstein barycenters with a Sinkhorn divergence, using Eulerian and Lagrangian...">

.. only:: html

  .. image:: /_auto_examples/optimal_transport/images/thumb/sphx_glr_plot_wasserstein_barycenters_1D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_optimal_transport_plot_wasserstein_barycenters_1D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Wasserstein barycenters in 1D</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s compute pseudo-Wasserstein barycenters between 2D densities, using the gradient of the Si...">

.. only:: html

  .. image:: /_auto_examples/optimal_transport/images/thumb/sphx_glr_plot_wasserstein_barycenters_2D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_optimal_transport_plot_wasserstein_barycenters_2D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Wasserstein barycenters in 2D</div>
    </div>


.. raw:: html

    </div>

Performances
----------------

Select the hyper-parameters that are best suited to your data:



.. raw:: html

    <div class="sphx-glr-thumbnails">


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Utility routines for benchmarks on OT solvers">

.. only:: html

  .. image:: /_auto_examples/performances/images/thumb/sphx_glr_benchmarks_ot_solvers_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_performances_benchmarks_ot_solvers.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Utility routines for benchmarks on OT solvers</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s compare the performances of several OT solvers on subsampled versions of the Stanford dra...">

.. only:: html

  .. image:: /_auto_examples/performances/images/thumb/sphx_glr_plot_benchmarks_ot_3D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_performances_plot_benchmarks_ot_3D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Wasserstein distances between large point clouds</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Let&#x27;s compare the performances of our losses and backends as the number of samples grows from 1...">

.. only:: html

  .. image:: /_auto_examples/performances/images/thumb/sphx_glr_plot_benchmarks_samplesloss_3D_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_performances_plot_benchmarks_samplesloss_3D.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Benchmark SamplesLoss in 3D</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example explains how to profile the geometric losses to select the backend and truncation/...">

.. only:: html

  .. image:: /_auto_examples/performances/images/thumb/sphx_glr_plot_profile_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_performances_plot_profile.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Profile the GeomLoss routines</div>
    </div>


.. raw:: html

    </div>

Scaling up to brain tractograms -- with Pierre Roussillon
-------------------------------------------------------------

Use unbalanced, regularized Optimal Transport to process
white matter fiber tracks.
The scripts presented below should allow you to reproduce
the experiments of the `Miccai 2019 <https://www.miccai2019.org/>`_ paper
**Fast and scalable Optimal Transport for brain tractograms**
by Jean Feydy\*, Pierre Roussillon\*, Alain Trouvé and Pietro Gori.



.. raw:: html

    <div class="sphx-glr-thumbnails">


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this tutorial, we compute the barycenter of a dataset of probability tracks.  The barycenter...">

.. only:: html

  .. image:: /_auto_examples/brain_tractograms/images/thumb/sphx_glr_track_barycenter_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_brain_tractograms_track_barycenter.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Create an atlas using Wasserstein barycenters</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Input-Output with brain tractograms">

.. only:: html

  .. image:: /_auto_examples/brain_tractograms/images/thumb/sphx_glr_tract_io_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_brain_tractograms_tract_io.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Input-Output with brain tractograms</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="We use a new multiscale algorithm for solving regularized Optimal Transport  problems on the GP...">

.. only:: html

  .. image:: /_auto_examples/brain_tractograms/images/thumb/sphx_glr_transfer_labels_thumb.png
    :alt:

  :ref:`sphx_glr__auto_examples_brain_tractograms_transfer_labels.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Transferring labels from a segmented atlas</div>
    </div>


.. raw:: html

    </div>


.. toctree::
   :hidden:
   :includehidden:


   /./_auto_examples/comparisons/index.rst
   /./_auto_examples/sinkhorn_multiscale/index.rst
   /./_auto_examples/optimal_transport/index.rst
   /./_auto_examples/performances/index.rst
   /./_auto_examples/brain_tractograms/index.rst


.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-gallery

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download all examples in Python source code: _auto_examples_python.zip </_auto_examples/_auto_examples_python.zip>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download all examples in Jupyter notebooks: _auto_examples_jupyter.zip </_auto_examples/_auto_examples_jupyter.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_