Hall Projection
log_signatures_pytorch.hall_projection.HallProjector
dataclass
Projector from tensor algebra coordinates to Hall basis coordinates.
This class computes and caches projection matrices that convert log-signature tensors from tensor algebra coordinates to Hall basis coordinates. The projection matrices are computed using QR decomposition or pseudoinverse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Path dimension (size of the alphabet). |
required |
depth
|
int
|
Truncation depth. |
required |
device
|
device
|
Device on which to store projection matrices. |
required |
dtype
|
dtype
|
Data type for projection matrices. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
width |
int
|
Path dimension. |
depth |
int
|
Truncation depth. |
device |
device
|
Device for projection matrices. |
dtype |
dtype
|
Data type for projection matrices. |
Examples:
>>> import torch
>>> from log_signatures_pytorch.hall_projection import HallProjector
>>>
>>> projector = HallProjector(width=2, depth=2, device=torch.device("cpu"), dtype=torch.float32)
>>> # Project log-signature tensors
>>> log_sig_tensors = [
... torch.tensor([[1.0, 2.0]]), # depth 1
... torch.tensor([[[0.5, 0.3], [0.2, 0.1]]]), # depth 2
... ]
>>> result = projector.project(log_sig_tensors)
>>> result.shape
torch.Size([1, 3])
Source code in src/log_signatures_pytorch/hall_projection.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
project(log_sig_tensors)
Project log-signature tensors onto Hall basis.
Converts log-signature tensors from tensor algebra coordinates to Hall basis coordinates using precomputed projection matrices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_sig_tensors
|
List[Tensor]
|
List of log-signature tensors in tensor algebra coordinates, where
entry |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of shape |
Examples:
>>> import torch
>>> from log_signatures_pytorch.hall_projection import HallProjector
>>>
>>> projector = HallProjector(width=2, depth=2, device=torch.device("cpu"), dtype=torch.float32)
>>> log_sig_tensors = [
... torch.tensor([[1.0, 2.0]]), # depth 1: (batch=1, width=2)
... torch.tensor([[[0.5, 0.3], [0.2, 0.1]]]), # depth 2: (batch=1, width=2, width=2)
... ]
>>> result = projector.project(log_sig_tensors)
>>> result.shape
torch.Size([1, 3])
Source code in src/log_signatures_pytorch/hall_projection.py
log_signatures_pytorch.hall_projection.get_hall_projector(width, depth, device, dtype)
Get or create a cached Hall projector.
Returns a cached :class:HallProjector instance for the given parameters.
Projectors are cached to avoid recomputing projection matrices for the same
width, depth, device, and dtype combination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Path dimension (size of the alphabet). |
required |
depth
|
int
|
Truncation depth. |
required |
device
|
device
|
Device on which to store projection matrices. |
required |
dtype
|
dtype
|
Data type for projection matrices. |
required |
Returns:
| Type | Description |
|---|---|
HallProjector
|
A cached projector instance for the specified parameters. |
Examples:
>>> import torch
>>> from log_signatures_pytorch.hall_projection import get_hall_projector
>>>
>>> # First call creates and caches the projector
>>> projector1 = get_hall_projector(2, 2, torch.device("cpu"), torch.float32)
>>>
>>> # Second call returns the cached projector
>>> projector2 = get_hall_projector(2, 2, torch.device("cpu"), torch.float32)
>>> projector1 is projector2
True
Source code in src/log_signatures_pytorch/hall_projection.py
log_signatures_pytorch.hall_projection.hall_basis(width, depth)
Return Hall basis elements up to depth over an alphabet of size width.
The Hall basis is a particular basis for the free Lie algebra. Elements are ordered first by depth, then lexicographically by the recursive Hall ordering. Degree-1 elements are labeled 1..width and higher degrees are nested tuples representing Lie brackets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Size of the alphabet (path dimension). Must be >= 1. |
required |
depth
|
int
|
Maximum depth to generate basis elements. Must be >= 1. |
required |
Returns:
| Type | Description |
|---|---|
List[HallBasisElement]
|
Hall basis elements, where each element is either an integer (degree 1) or a nested tuple representing a Lie bracket (higher degrees). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/log_signatures_pytorch/hall_projection.py
log_signatures_pytorch.hall_projection.logsigdim(width, depth)
log_signatures_pytorch.hall_projection.logsigkeys(width, depth)
Human-readable labels for Hall basis elements (esig-compatible).