pysiglib.branched_sig_to_log_sig_backprop#
- branched_sig_to_log_sig_backprop(bsig, blogsig_derivs, dimension, degree, *, time_aug=False, lead_lag=False, planar=False, n_jobs=1)[source]#
Backpropagates through the
pysiglib.branched_sig_to_log_sigfunction. Given the derivatives of a scalar function \(F\) with respect to the branched log signature, returns the derivatives of \(F\) with respect to the branched signature.- Parameters:
bsig (numpy.ndarray | torch.tensor) – The branched signature or batch of branched signatures used in the forward pass, given as a numpy.ndarray or torch.tensor. For a single branched signature, this must be of shape
branched_sig_length. For a batch of paths, this must be of shape(batch_size, branched_sig_length). The leading scalar term may be present or omitted.blogsig_derivs (numpy.ndarray | torch.tensor) – Derivatives of the scalar function \(F\) with respect to the branched log signature(s). This must be an array of the same shape as the branched log signature(s).
dimension (int) – Dimension of the underlying path(s).
degree (int) – Truncation degree of the branched signature(s).
time_aug (bool) – Whether the branched signature(s) were computed with
time_aug=True.lead_lag (bool) – Whether the branched signature(s) were computed with
lead_lag=True.planar (bool) – If True, use planar branched signatures.
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 branched signature(s). This is an array of the same shape as
bsig.- Return type:
numpy.ndarray | torch.tensor
Example:#
import torch import pysiglib path = torch.rand((10, 100, 5)) bsig = pysiglib.branched_sig(path, 3) blogsig = pysiglib.branched_sig_to_log_sig(bsig, 5, 3) blogsig_derivs = torch.ones_like(blogsig) bsig_derivs = pysiglib.branched_sig_to_log_sig_backprop( bsig, blogsig_derivs, 5, 3, ) print(bsig_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}
}