All Projects → GPflow → GeometricKernels

GPflow / GeometricKernels

Licence: Apache-2.0 license
Geometric kernels on manifolds, meshes and graphs

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language
Makefile
30231 projects

WARNING: this is a development (unstable) version of the package

Geometric Kernels

Geometric Kernels is a library that implements natural kernels (Heat, Matérn) on such non-Euclidean spaces as Riemannian manifolds or graphs.

The main projected application is within the Gaussian process framework. Some of the features are specifically inspired by it, most notably by the problem of efficient sampling.

Installation

  1. [Optionally] install and run virtualenv
[sudo] pip install virtualenv
virtualenv [env_name]
source [env_name]/bin/activate
  1. [Prerequisite] install LAB following these instructions.

  2. Install the library in the active environment by running

pip install git+https://github.com/gpflow/geometrickernels.git
  1. Install a backend of your choice

We use LAB to support multiple backends (e.g., TensorFlow, Jax, PyTorch). However, you are not required to install all of them on your system to use the Geometric Kernel package. Simply install the backend (and (optionally) a GP package) of your choice. For example,

  • TensorFlow and GPflow
pip install tensorflow tensorflow-probability gpflow
  • PyTorch and GPyTorch
pip install torch gpytorch
  • JAX (the cpu version)
pip install "jax[cpu]"

Supported backends with associated GP packaes

Ready Backend GP package
Tensorflow GPflow
PyTorch GPyTorch
Numpy -
JAX -

A basic example

This example shows how to compute a 3x3 kernel matrix for the Matern52 kernel on the standard two-dimensional sphere. It relies on the numpy-based backend. Look up the information on how to use other backends in the documentation.

# Import a backend.
import numpy as np
# Import the geometric_kernels backend.
import geometric_kernels
# Import a space and an appropriate kernel.
from geometric_kernels.spaces.hypersphere import Hypersphere
from geometric_kernels.kernels.geometric_kernels import MaternKarhunenLoeveKernel

# Create a manifold (2-dim sphere).
hypersphere = Hypersphere(dim=2)

# Generate 3 random points on the sphere.
xs = np.array([[0., 0., 1.], [0., 1., 0.], [1., 0., 0.]])

# Initialize kernel, use 100 terms to approximate the infinite series.
kernel = MaternKarhunenLoeveKernel(hypersphere, 100)
params, state = kernel.init_params_and_state()
params["nu"] = np.array([5/2])
params["lengthscale"] = np.array([1.])

# Compute and print out the 3x3 kernel matrix.
print(kernel.K(params, state, xs))

This should output

[[0.00855354 0.00305004 0.00305004]
 [0.00305004 0.00855354 0.00305004]
 [0.00305004 0.00305004 0.00855354]]

Documentation

The documentation for GeometricKernels is available on a separate website.

For development and running the tests

Run these commands from the root directory of the repository.

Install all backends and the dev requirements (Pytest, black, etc.)

pip install -r dev_requirements.txt -r requirements.txt

Run the tests

make test

The structure of the library

class diagram

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].