pysiglib.sig_combine_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.
- sig_combine_backprop(deriv, sig1, sig2, dimension, degree, *, time_aug=False, lead_lag=False, n_jobs=1)[source]#
This function is required to backpropagate through
pysiglib.sig_combine. Given the derivatives of a scalar function \(F\) with respect to the result ofpysiglib.sig_combine, \(\partial F / \partial S(x_1 * x_2)\), returns the derivatives of \(F\) with respect to the original two signatures, \(\partial F / \partial S(x_1)\) and \(\partial F / \partial S(x_2)\).- Parameters:
deriv – Derivative with respect to the combined signature, \(\partial F / \partial S(x_1 * x_2)\)
sig1 (numpy.ndarray | torch.tensor) – The first truncated signature
sig2 (numpy.ndarray | torch.tensor) – The second truncated signature. Must have the same degree and dimension as the first.
dimension (int) – Dimension of the underlying space, \(d\).
degree (int) – Truncation level of the signatures, \(N\)
time_aug (bool) – Whether time augmentation was applied before computing the signature.
lead_lag (bool) – Whether the lead lag transformation was applied before computing the signature.
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
sig1andsig2, in the same scalar-term format as the inputs.- Return type:
Tuple[numpy.ndarray | torch.tensor, numpy.ndarray | torch.tensor]
Example:#
import numpy as np import pysiglib batch_size, length, dimension, degree = 10, 100, 5, 3 X1 = np.random.uniform(size=(batch_size, length, dimension)) X2 = np.random.uniform(size=(batch_size, length, dimension)) sig1 = pysiglib.sig(X1, degree, time_aug=True) sig2 = pysiglib.sig(X2, degree, time_aug=True) combined = pysiglib.sig_combine(sig1, sig2, dimension, degree, time_aug=True) derivs = np.ones_like(combined) dsig1, dsig2 = pysiglib.sig_combine_backprop( derivs, sig1, sig2, dimension, degree, time_aug=True ) print(dsig1)
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}
}