log_signature¶
Compute log-signatures for batched paths.
The log-signature is a compressed representation of the signature. Two bases are supported:
mode="words"(default): Signatory-style Lyndon words basis (triangular/gather projection)mode="hall": classic Hall basis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Tensor
|
Tensor of shape |
required |
depth
|
int
|
Maximum depth to truncate log-signature computation. The output dimension
is |
required |
stream
|
bool
|
If True, computed log-signatures are returned for each step. Default is False. |
False
|
method
|
str
|
Computation method: "default" (signature then log) or "bch_sparse" (sparse Hall-BCH). The default remains signature then log because the ambient Hall bracket table and higher-order BCH expansion can be more expensive than tensor-algebra computation. Default is "default". |
'default'
|
mode
|
str
|
Basis for the log-signature coordinates: "words" (default) or "hall".
"words" is only available with |
'words'
|
sparse
|
bool
|
If True, use sparse signature computation for paths with repeated points.
Only applies when |
False
|
eps
|
float
|
Threshold for change detection when using sparse mode. Default is 0.0. |
0.0
|
lengths
|
Tensor
|
Tensor of shape |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
If If |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
>>> import torch
>>> from tensorsig.algebra.hall import logsigdim
>>> from tensorsig.classical.signatures import log_signature
>>> from tensorsig.algebra.lyndon import logsigdim_words
>>>
>>> # Single path (add batch dimension)
>>> path = torch.tensor([[0.0, 0.0], [1.0, 1.0], [2.0, 0.0]]).unsqueeze(0)
>>> log_sig = log_signature(path, depth=2)
>>> log_sig.shape
torch.Size([1, 3])
>>> logsigdim_words(2, 2)
3
>>>
>>> # Batched paths
>>> batch_paths = torch.tensor([
... [[0.0, 0.0], [1.0, 1.0]],
... [[0.0, 0.0], [2.0, 2.0]],
... ])
>>> log_sig = log_signature(batch_paths, depth=2)
>>> log_sig.shape
torch.Size([2, 3])
>>>
>>> # Streaming log-signatures
>>> log_sig_stream = log_signature(path, depth=2, stream=True)
>>> log_sig_stream.shape
torch.Size([1, 2, 3])
>>>
>>> # Using the direct BCH method in Hall coordinates
>>> log_sig_bch = log_signature(path, depth=2, method="bch_sparse", mode="hall")
>>> log_sig_bch.shape
torch.Size([1, 3])
Source code in src/tensorsig/classical/log_signature.py
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 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 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |