Signature
log_signatures_pytorch.signature.signature(path, depth, stream=False)
Compute signatures for batched paths.
The signature of a path is a collection of iterated integrals that captures the path's geometric properties. It is computed as a truncated tensor series up to the specified depth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Tensor
|
Tensor of shape |
required |
depth
|
int
|
Maximum depth to truncate signature computation. The output dimension
will be |
required |
stream
|
bool
|
If True, return signatures at each step along the path. If False, return only the final signature. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
Tensor
|
If If |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
>>> import torch
>>> from log_signatures_pytorch import signature
>>>
>>> # Single path (add batch dimension)
>>> path = torch.tensor([[0.0, 0.0], [1.0, 1.0], [2.0, 0.0]]).unsqueeze(0)
>>> sig = signature(path, depth=2)
>>> sig.shape
torch.Size([1, 6])
>>>
>>> # Batched paths
>>> batch_paths = torch.tensor([
... [[0.0, 0.0], [1.0, 1.0]],
... [[0.0, 0.0], [2.0, 2.0]],
... ])
>>> sig = signature(batch_paths, depth=2)
>>> sig.shape
torch.Size([2, 6])
>>>
>>> # Streaming signatures
>>> sig_stream = signature(path, depth=2, stream=True)
>>> sig_stream.shape
torch.Size([1, 2, 6])
Source code in src/log_signatures_pytorch/signature.py
log_signatures_pytorch.signature.signature_inverse(levels)
Inverse of a truncated signature via Chen's recursion.
Computes the inverse of a signature represented as a list of level tensors, where each level corresponds to a depth in the truncated signature series. The inverse is computed recursively using Chen's identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
levels
|
list[Tensor]
|
List of tensors representing the signature levels. Each tensor at index
|
required |
Returns:
| Type | Description |
|---|---|
list[Tensor]
|
List of tensors representing the inverse signature, with the same structure
as the input |
Examples:
>>> import torch
>>> from log_signatures_pytorch.signature import signature_inverse
>>>
>>> # Create a simple signature (depth=2, width=2)
>>> level1 = torch.tensor([[[1.0, 2.0]]]) # (batch=1, width=2)
>>> level2 = torch.tensor([[[[0.5, 0.3], [0.2, 0.1]]]]) # (batch=1, width=2, width=2)
>>> levels = [level1, level2]
>>>
>>> # Compute inverse
>>> inv_levels = signature_inverse(levels)
>>> len(inv_levels)
2
Source code in src/log_signatures_pytorch/signature.py
log_signatures_pytorch.signature.signature_multiply(left, right)
Chen product of two truncated signatures.
Computes the product of two signatures represented as lists of level tensors using Chen's identity. This corresponds to the signature of the concatenation of two paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left
|
list[Tensor]
|
List of tensors representing the first signature levels. Each tensor at
index |
required |
right
|
list[Tensor]
|
List of tensors representing the second signature levels, with the same
structure as |
required |
Returns:
| Type | Description |
|---|---|
list[Tensor]
|
List of tensors representing the product signature, with the same structure as the input signatures. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
>>> import torch
>>> from log_signatures_pytorch.signature import signature_multiply
>>>
>>> # Create two signatures (depth=2, width=2)
>>> left_level1 = torch.tensor([[[1.0, 2.0]]])
>>> left_level2 = torch.tensor([[[[0.5, 0.3], [0.2, 0.1]]]])
>>> left = [left_level1, left_level2]
>>>
>>> right_level1 = torch.tensor([[[0.5, 1.0]]])
>>> right_level2 = torch.tensor([[[[0.2, 0.1], [0.1, 0.05]]]])
>>> right = [right_level1, right_level2]
>>>
>>> # Compute product
>>> product = signature_multiply(left, right)
>>> len(product)
2
Source code in src/log_signatures_pytorch/signature.py
log_signatures_pytorch.signature.stream_to_window_signatures(signature, depth, window_size, hop_size)
Compute sliding-window signatures from a stream-computed signature.
This function applies Chen's identity to a pre-computed stream of signatures to obtain signatures for sliding windows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signature
|
Tensor
|
Tensor of shape |
required |
depth
|
int
|
Maximum depth of the signatures. |
required |
window_size
|
int
|
Number of path points per window. |
required |
hop_size
|
int
|
Step between consecutive window starts. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape |
Source code in src/log_signatures_pytorch/signature.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
log_signatures_pytorch.signature.windowed_signature(path, depth, window_size, hop_size)
Sliding-window signatures using Chen's identity.
Each window signature is computed from streaming prefix signatures:
Sig(path[s:e]) = Sig(path[:s])^{-1} ⊗ Sig(path[:e]) where e = s + window_size - 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Tensor
|
Tensor of shape |
required |
depth
|
int
|
Maximum depth to truncate signature computation. |
required |
window_size
|
int
|
Number of path points per window. |
required |
hop_size
|
int
|
Step between consecutive window starts ( |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
- Implements the Signatory-style streaming reuse (Chen) without materializing every window explicitly.
- Provides the building block for :func:
windowed_log_signature; both share identical window indexing and batching semantics.