Skip to main content

Fast Signature Computations on CPU and GPU

Project description

Logo

Fast Signature Computations on CPU and GPU

PyPI - Version PyPI - Downloads CI - Test codecov Read the Docs GitHub License

Installation

Before installing, please ensure you have a compatible C++ compiler installed (MSVC for Windows, GCC or Clang for Linux and MacOS), then run

pip install pysiglib

pySigLib will automatically detect CUDA, provided the CUDA_PATH environment variable is set correctly. To manually disable CUDA and build pySigLib for CPU only, create an environment variable CUSIG and set it to 0:

set CUSIG=0
pip install pysiglib

For detailed and up-to-date installation instructions on Windows, Linux and MacOS, see the installation guide.

Documentation

Full documentation is available at https://pysiglib.readthedocs.io

Examples

Signatures

pySigLib implements truncated signature transforms through the function pysiglib.signature, which takes as input a path or batch of paths X, and a truncation degree.

X can be a numpy array or a torch tensor. For a single path, X must be of shape (path length, path dimension). For a batch of paths, it must be of shape (batch size, path length, path dimension).

The computation will run on whichever device X is on. For example, passing X = np.random.uniform(size=(32, 1000, 10)) will trigger the computation to run on the CPU, whilst X = torch.rand(32, 1000, 10, device = "cuda") will run on the CUDA device.

import pysiglib
import numpy as np

X = np.random.uniform(size=(32, 1000, 10))
sig = pysiglib.signature(X, degree = 5)

Signature Kernels

pySigLib implements signature kernels through the function pysiglib.sig_kernel, which takes as input a pair of paths or a pair of batches of paths X, Y. The dyadic_order parameter can be used to refine the PDE grid, giving more accurate results. If specified as an integer, the same refinement factor is applied to both X and Y. To apply different factors to the two paths, dyadic_order can be specified as a tuple.

As with signatures, X,Y can be numpy arrays or torch tensors, and must have the same shapes as described above. Again, the computation will run on whichever device X,Y are located on.

import pysiglib
import numpy as np

X = np.random.uniform(size=(32, 1000, 10))
Y = np.random.uniform(size=(32, 1000, 10))
sig = pysiglib.sig_kernel(X, Y, dyadic_order=1)

# In cases where the paths differ in length, it may
# be advantageous to refine the PDE grid by different
# amounts for X and Y:

X = np.random.uniform(size=(32, 100, 10))
Y = np.random.uniform(size=(32, 5000, 10))
sig = pysiglib.sig_kernel(X, Y, dyadic_order=(3, 0))

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

pysiglib-0.2.1.tar.gz (204.3 kB view details)

Uploaded Source

File details

Details for the file pysiglib-0.2.1.tar.gz.

File metadata

  • Download URL: pysiglib-0.2.1.tar.gz
  • Upload date:
  • Size: 204.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pysiglib-0.2.1.tar.gz
Algorithm Hash digest
SHA256 532bd89c6c6b12335624c2fbc09e7de3cd5a25bb7f9511df5926ae357bc93be1
MD5 95ce1ef550713aab7ae30e2b315f8a2f
BLAKE2b-256 7ca0f33e2e0570eb98e21c5bd2a45e071f27cfc2dda88b55ef444c65d7ca267b

See more details on using hashes here.

Supported by

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