pathsig.LogSignature#
- class pathsig.LogSignature(depth, projection=None, windows=None)#
Computes the log-signature of a path.
- Parameters:
depth (int) – Truncation level.
projection (object | None) – (optional) Projection controlling which log-signature coordinates are computed and returned. See pathsig.projections for supported types.
windows (torch.Tensor | None) – (optional) Integer tensor of shape \((W,2)\) specifying windows \([start,end)\).
- forward(x)#
- Parameters:
x (torch.Tensor) – CUDA tensor of shape \((B,T,d)\) with dtype
float32orfloat64.- Returns:
Tensor of shape \((B,D)\) if
windowsisNone, and \((B,W,D)\) otherwise.- Return type:
torch.Tensor
Here \(B\) is the batch size, \(T\) the sequence length, \(d\) the path dimension, \(W\) the number of windows, and \(D\) the output dimension. If no projection is provided then \(D=\sum_{k=1}^{\mathrm{depth}} d^k\). With a projection, \(D=\texttt{projection.sig\_size}\).
Notes
For a compact coordinate representation of the log-signature, a projection should be specified. A canonical choice is the Lyndon projection.
Autograd is supported for
float32andfloat64in both windowed and non-windowed modes, with or without a projection.Examples
import torch import pathsig x = torch.randn(32, 128, 8, device="cuda", dtype=torch.float32) # (B, T, d) # Log-signature with a Lyndon projection proj = pathsig.projections.lyndon(depth=4, path_dim=8) logsig = pathsig.LogSignature(depth=4, projection=proj) y = logsig(x) # (B, proj.sig_size) # Windowed log-signature with a Lyndon projection windows = torch.tensor([[0, 32], [32, 64]], device="cuda") # (W, 2) logsig = pathsig.LogSignature(depth=4, projection=proj, windows=windows) y = logsig(x) # (B, W, proj.sig_size) # Full truncated log-signature logsig = pathsig.LogSignature(depth=4) y = logsig(x) # (B, D)