pysiglib.sig_to_log_sig_backprop#
Added in version v1.0.0.
Warning
Where possible, pysiglib.torch_api should be used rather than explicitly calling
backpropagation functions. Explicit backpropagation can introduce subtle errors if called
incorrectly. In addition, some pysiglib functions can only be backpropagated through
using their pysiglib.torch_api variants and do not expose explicit backpropagation functions.
- sig_to_log_sig_backprop(sig, log_sig_derivs, dimension, degree, *, time_aug=False, lead_lag=False, method=1, n_jobs=1)[source]#
Backpropagates through the
pysiglib.sig_to_log_sigfunction. Given the derivatives of a scalar function \(F\) with respect to the log signature, \(\partial F / \partial \log(S(x))\), returns the derivatives of \(F\) with respect to the signature, \(\partial F / \partial S(x)\).- Parameters:
sig (numpy.ndarray | torch.tensor) – The signature or batch of signatures, given as a numpy.ndarray or torch.tensor. For a single signature, this must be of shape
sig_length. For a batch of paths, this must be of shape(batch_size, sig_length).log_sig_derivs (numpy.ndarray | torch.tensor) – Derivatives of the scalar function \(F\) with respect to the log signature(s), \(\partial F / \partial S(x)\). This must be an array of the same shape as the log signature(s).
dimension (int) – Dimension of the underlying path(s).
degree (int) – Truncation degree of the (log) signature(s).
time_aug (bool) – Whether the signatures were computed with
time_aug=True.lead_lag (bool) – Whether the signatures were computed with
lead_lag=True.method (int) – Method used for the log signature computation (0, 1 or 2).
n_jobs (int) – Number of threads to run in parallel. If n_jobs = 1, the computation is run serially. If set to -1, all available threads are used. For n_jobs below -1, (max_threads + 1 + n_jobs) threads are used. For example if n_jobs = -2, all threads but one are used.
- Returns:
Derivatives of the scalar function \(F\) with respect to the signature(s), \(\partial F / \partial S(x)\). This is an array of the same shape as the provided signature(s).
- Return type:
numpy.ndarray | torch.tensor
Example:#
import torch import pysiglib batch, length, dimension, degree = 10, 100, 5, 4 pysiglib.prepare_log_sig(dimension, degree, time_aug=True, method=1) path = torch.rand((batch, length, dimension)) sigs = pysiglib.sig(path, degree, time_aug=True) log_sigs = pysiglib.sig_to_log_sig(sigs, dimension, degree, time_aug=True, method=1) log_sig_derivs = torch.ones_like(log_sigs) sig_derivs = pysiglib.sig_to_log_sig_backprop( sigs, log_sig_derivs, dimension, degree, time_aug=True, method=1, ) print(sig_derivs)
Citation#
If you found this library useful in your research, please consider citing the paper:
@article{shmelev2025pysiglib,
title={pySigLib-Fast Signature-Based Computations on CPU and GPU},
author={Shmelev, Daniil and Salvi, Cristopher},
journal={arXiv preprint arXiv:2509.10613},
year={2025}
}