pysiglib.transform_path_backprop

pysiglib.transform_path_backprop#

Added in version v0.2.

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.

transform_path_backprop(derivs, *, time_aug=False, lead_lag=False, end_time=1.0, n_jobs=1)[source]#

This function is required to backpropagate through pysiglib.transform_path. Given the derivatives of a scalar function \(F\) with respect to the result of pysiglib.transform_path, \(\{\partial F / \partial \tilde{x}_{t_i}\}_{i=0}^\tilde{L}\), returns the derivatives of \(F\) with respect to the original path, \(\{\partial F / x_{t_i}\}_{i=0}^L\).

Parameters:
  • derivs (numpy.ndarray | torch.tensor) – The derivatives with respect to the result of pysiglib.transform_path, \(\{\partial F / \partial \tilde{x}_{t_i}\}_{i=0}^\tilde{L}\).

  • time_aug (bool) – If True, assumes the derivatives are with respect to a time augmented path.

  • lead_lag (bool) – If True, assumes the derivatives are with respect to a lead-lag transformed path.

  • end_time (float) – End time for time-augmentation, \(t_L\).

  • 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 with respect to the original path, \(\{\partial F / x_{t_i}\}_{i=0}^L\).

Return type:

numpy.ndarray | torch.tensor

Example:#

import torch
import pysiglib

path = torch.tensor([[0., 1.], [2., 3.]])
transformed = pysiglib.transform_path(path, time_aug=True, lead_lag=True)
derivs = torch.ones_like(transformed)
path_derivs = pysiglib.transform_path_backprop(derivs, time_aug=True, lead_lag=True)
print(path_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}
}