Skip to main content

Geodesic Sinkhorn with Chebyshev approximation

Project description

GeoSinkhorn

Code for the paper Geodesic Sinkhorn for Fast and Accurate Optimal Transport on Manifolds.

[!NOTE]
This repository is still in development.

Installation

You can install the library from PyPI by running:

pip install geosink

Or using Git, by first cloning the repository and running:

pip install -e .

If you want to use the pre existing graph tools, run:

pip install -e .['graph']

To run the tests, you will need additional packages. Install them by running:

pip install -e .['dev']

Minimal Example

You can reproduce this example in the following notebook notebook.

We build a graph between two Gaussian distributions and compute the distance between two signals on that graph.

import numpy as np
from geosink.sinkhorn import GeoSinkhorn 
from geosink.heat_kernel import laplacian_from_data

# Generate data and build graph.
data0 = np.random.normal(0, 1, (100, 5))
data1 = np.random.normal(5, 1, (100, 5))
data = np.concatenate([data0, data1], axis=0)
lap = laplacian_from_data(data, sigma=1.0)

# instantiate the GeoSinkhorn class
geo_sinkhorn = GeoSinkhorn(tau=5.0, order=10, method="cheb", lap=lap)

# create two signals
m_0 = np.zeros(200,)
m_0[:100] = 1
m_0 = m_0 / np.sum(m_0)
m_1 = np.zeros(200,)
m_1[100:] = 1
m_1 = m_1 / np.sum(m_1)

# compute the distance between the two signals
dist_w = geo_sinkhorn(m_0, m_1, max_iter=500)
print(dist_w)

Note that it is also possible to provide a graph instance directly to the GeoSinkhorn class with GeoSinkhorn(tau=1.0, order=10, method="cheb", graph=graph). The graph must have a Laplacian attribute graph.L. We suggest using a sparse Laplacian (e.g. in COO format) for better performance.

How to Cite

If you find this code useful in your research, please cite the following paper (expand for BibTeX):

Huguet, G., Tong, A., Zapatero, M. R., Tape, C. J., Wolf, G., & Krishnaswamy, S. (2023). Geodesic Sinkhorn for fast and accurate optimal transport on manifolds. In 2023 IEEE 33rd International Workshop on Machine Learning for Signal Processing (MLSP).
@inproceedings{huguet2023geodesic,
  title={Geodesic Sinkhorn for fast and accurate optimal transport on manifolds},
  author={Huguet, Guillaume and Tong, Alexander and Zapatero, Mar{\'\i}a Ramos and Tape, Christopher J and Wolf, Guy and Krishnaswamy, Smita},
  booktitle={2023 IEEE 33rd International Workshop on Machine Learning for Signal Processing (MLSP)},
  pages={1--6},
  year={2023},
  organization={IEEE}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geosink-0.2.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

geosink-0.2.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file geosink-0.2.0.tar.gz.

File metadata

  • Download URL: geosink-0.2.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for geosink-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2ee04d6f17905ec1d6289d225ba51408da78e99bce7dd82b711c30993258706d
MD5 7a763b0a8b9dd1fe637aae917ca5af78
BLAKE2b-256 33782966824fe5ba03a75e7f1d54cd6883ec6b4b1957ac1a76c076aae2a5a31f

See more details on using hashes here.

File details

Details for the file geosink-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: geosink-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for geosink-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6bf065dfd9d10d6651d190dafe4a70f93b61dca98b371af1e42ee21f511a379b
MD5 f291fe3899429cb79e4fdbbc9dac8f47
BLAKE2b-256 084f84bd70757ff46bcf8aafe7d24e46e98069d230434c3d268090d8cd7093e8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page