pysiglib.log_sig_join_backprop#
Added in version v3.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.
- log_sig_join_backprop(d_out, log_sig, displacement, dimension, degree, *, n_jobs=1)[source]#
This function is required to backpropagate through
pysiglib.log_sig_join. Given the derivatives of a scalar function \(F\) with respect to the result ofpysiglib.log_sig_join, \(\partial F / \partial L(x * v)\), returns the derivatives of \(F\) with respect to the original log-signature and the displacement vector, \(\partial F / \partial L(x)\) and \(\partial F / \partial v\).Note
log_sigis expected in the Lyndon bracket basis (method=2output). You must callpysiglib.prepare_log_sig(dimension, degree, method=2)before using this function. This precomputes the Lyndon basis and BCH coefficients needed internally.- Parameters:
d_out (numpy.ndarray | torch.tensor) – Derivative with respect to the output of log_sig_join, \(\partial F / \partial L(x * v)\), of shape
(..., log_sig_length).log_sig (numpy.ndarray | torch.tensor) – The original truncated log-signature, \(L(x)\), of shape
(..., log_sig_length).displacement (numpy.ndarray | torch.tensor) – The displacement vector, \(v\), of shape
(..., dimension).dimension (int) – Dimension of the underlying space, \(d\).
degree (int) – Truncation level of the log-signatures, \(N\)
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
log_siganddisplacement- Return type:
Tuple[numpy.ndarray | torch.tensor, numpy.ndarray | torch.tensor]
Example:#
import numpy as np import pysiglib dimension, degree = 5, 3 pysiglib.prepare_log_sig(dimension, degree, method=2) path = np.random.uniform(size=(100, dimension)) ls = pysiglib.log_sig(path, degree, method=2) displacement = np.random.uniform(size=(dimension,)) extended = pysiglib.log_sig_join(ls, displacement, dimension, degree) d_out = np.ones_like(extended) d_logsig, d_displacement = pysiglib.log_sig_join_backprop( d_out, ls, displacement, dimension, degree ) print(d_logsig.shape, d_displacement.shape)
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}
}