signature¶
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 tensorsig.classical.signatures 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])