GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • GeomLoss
  • Getting started
  • Maths and algorithms
  • API
  • Gallery of examples
  • View page source

This view

  • Original page
  • New address

GeezerVison is showing www.kernel-operations.io — Geometric Loss functions between sampled measures, images and volumes — GeomLoss

Geometric Loss functions between sampled measures, images and volumes

The GeomLoss library provides efficient GPU implementations for:

  • Kernel norms (also known as Maximum Mean Discrepancies).

  • Hausdorff divergences, which are positive definite generalizations of the Chamfer-ICP loss and are analogous to log-likelihoods of Gaussian Mixture Models.

  • Debiased Sinkhorn divergences, which are affordable yet positive and definite approximations of Optimal Transport (Wasserstein) distances.

Note

We're hiring! A two-year postdoctoral position in Paris is currently open.

It is hosted on GitHub and distributed under the permissive MIT license.
PyPi version Downloads

GeomLoss functions are available through the custom PyTorch layers SamplesLoss, ImagesLoss and VolumesLoss which allow you to work with weighted point clouds (of any dimension), density maps and volumetric segmentation masks. Geometric losses come with three backends each:

  • A simple tensorized implementation, for small problems (< 5,000 samples).

  • A reference online implementation, with a linear (instead of quadratic) memory footprint, that can be used for finely sampled measures.

  • A very fast multiscale code, which uses an octree-like structure for large-scale problems in dimension <= 3.

A typical sample of code looks like:

import torch
from geomloss import SamplesLoss  # See also ImagesLoss, VolumesLoss

# Create some large point clouds in 3D
x = torch.randn(100000, 3, requires_grad=True).cuda()
y = torch.randn(200000, 3).cuda()

# Define a Sinkhorn (~Wasserstein) loss between sampled measures
loss = SamplesLoss(loss="sinkhorn", p=2, blur=.05)

L = loss(x, y)  # By default, use constant weights = 1/number of samples
g_x, = torch.autograd.grad(L, [x])  # GeomLoss fully supports autograd!

GeomLoss is a simple interface for cutting-edge Optimal Transport algorithms. It provides:

  • Support for batchwise computations.

  • Linear (instead of quadratic) memory footprint for large problems, relying on the KeOps library for map-reduce operations on the GPU.

  • Fast kernel truncation for small bandwidths, using an octree-based structure.

  • Log-domain stabilization of the Sinkhorn iterations, eliminating numeric overflows for small values of \(\varepsilon\).

  • Efficient computation of the gradients, which bypasses the naive backpropagation algorithm.

  • Support for unbalanced Optimal Transport, with a softening of the marginal constraints through a maximum reach parameter.

  • Support for the ε-scaling heuristic in the Sinkhorn loop, with kernel truncation in dimensions 1, 2 and 3. On typical 3D problems, our implementation is 50-100 times faster than the standard SoftAssign/Sinkhorn algorithm.

Note, however, that SamplesLoss does not implement the Fast Multipole or Fast Gauss transforms. If you are aware of a well-packaged implementation of these algorithms on the GPU, please contact me!

The divergences implemented here are all symmetric, positive definite and therefore suitable for measure-fitting applications. For positive input measures \(\alpha\) and \(\beta\), our \(\text{Loss}\) functions are such that

\[\begin{split}\text{Loss}(\alpha,\beta) ~&=~ \text{Loss}(\beta,\alpha), \\ 0~=~\text{Loss}(\alpha,\alpha) ~&\leqslant~ \text{Loss}(\alpha,\beta), \\ 0~=~\text{Loss}(\alpha,\beta)~&\Longleftrightarrow~ \alpha = \beta.\end{split}\]

GeomLoss can be used in a wide variety of settings, from shape analysis (LDDMM, optimal transport…) to machine learning (kernel methods, GANs…) and image processing. Details and examples are provided below:

  • Maths and algorithms

  • PyTorch API

  • Source code

  • Examples

This website was rendered on a Dell workstation with an Intel Xeon W-2255 CPU (3.70GHz), 64 Gb RAM and a NVIDIA GeForce RTX 3090 GPU (24 Gb VRAM).

Author and Contributors

Feel free to contact us for any bug report or feature request:

  • Jean Feydy

  • Pierre Roussillon (extensions to brain tractograms and normal cycles)

Licensing, academic use

This library is licensed under the permissive MIT license, which is fully compatible with both academic and commercial applications. If you use this code in a research paper, please cite:

@inproceedings{feydy2019interpolating,
    title={Interpolating between Optimal Transport and MMD using Sinkhorn Divergences},
    author={Feydy, Jean and S{\'e}journ{\'e}, Thibault and Vialard, Fran{\c{c}}ois-Xavier and Amari, Shun-ichi and Trouve, Alain and Peyr{\'e}, Gabriel},
    booktitle={The 22nd International Conference on Artificial Intelligence and Statistics},
    pages={2681--2690},
    year={2019}
}

Related projects

You may be interested by:

  • The KeOps library, which provides efficient CUDA routines for point cloud processing, with full PyTorch support.

  • Rémi Flamary’s Python Optimal Transport library, which provides a reference implementation of OT-related methods for small problems.

  • Bernhard Schmitzer’s Optimal Transport toolbox, which provides a reference multiscale solver for the OT problem, on the CPU.

Table of contents

  • Getting started
    • Install with pip (recommended)
    • Install with git
    • Build the documentation on Google Cloud
    • Build the documentation on Google Colab
  • Maths and algorithms
  • API
    • SamplesLoss
    • solve()
    • solve_batch()
    • OTResultMatrix
    • solve_sample()
    • OTResultSample
    • LinearOperator
  • Gallery of examples
    • Kernel vs. Hausdorff vs. Sinkhorn
    • The multiscale Sinkhorn algorithm
    • Optimal Transport
    • Performances
    • Scaling up to brain tractograms – with Pierre Roussillon
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.