Map increment streams (B,T,C) to quotient windows (B,N,D).
A projected alphabet without offset_code uses certified raw Pascal
codes. A supplied code tensor supports independent windows and gradients
in that tensor. Rolling transport requires the certified default code.
derivative_order is selection metadata, not a switch that disables
autograd. The default is 1; use 2 when requesting higher-order derivatives.
Automatic choices use fixed schedules; choose an explicit algorithm to set
backend, shift_backend, chunk_windows or refresh_every. Explicit rolling
transport defaults to dense; the automatic typed rule records sparse.
GPU auto is restricted to the typed FIFO region and raises NotImplementedError
elsewhere; explicit algorithms retain their existing capabilities. CPU auto
uses direct independent windows. Selection is not an accuracy certificate.
Source code in src/tensorsig/offset_coded_signatures/windows.py
| def __init__(
self, plan: LieQuotientPlan, window: int, *, offset_code: Tensor | None = None
):
if not isinstance(plan, LieQuotientPlan):
raise TypeError("plan must be a LieQuotientPlan.")
_positive_integer(window, "window")
self.plan, self.window = plan, window
self._pascal = False
if isinstance(plan.alphabet, ProjectedAlphabet):
if offset_code is None:
if plan.alphabet.temporal_degrees != tuple(
range(plan.alphabet.code_dim)
):
raise ValueError(
"Supply offset_code for an uncertified projected alphabet."
)
if plan.alphabet.code_dim > window:
raise ValueError("Pascal width must not exceed window.")
self._pascal = True
offset_code = torch.tensor(
[
[comb(r, p) for p in range(plan.alphabet.code_dim)]
for r in range(window)
],
dtype=torch.float64,
)
if (
not isinstance(offset_code, Tensor)
or not offset_code.dtype.is_floating_point
):
raise TypeError("offset_code must be a floating-point tensor.")
if tuple(offset_code.shape) != (window, plan.alphabet.code_dim):
raise ValueError("offset_code shape must be (window, code_dim).")
elif isinstance(plan.alphabet, OffsetAlphabet):
if offset_code is not None or window != plan.alphabet.kernel_size:
raise ValueError(
"An offset alphabet requires its own window size and no code."
)
self._offset_code = offset_code
self._pascal_codes = {}
self._rolling = {}
self._auto_graph = None
if self._pascal and plan.alphabet.code_dim == 2 and plan.max_depth == 3:
if plan.quotient == LieQuotient(TemporalDegree(1)):
self._auto_graph = False
elif plan.quotient == LieQuotient(
TemporalDegree(1),
DependenceGraph(
(i, i + 1) for i in range(plan.alphabet.in_channels - 1)
),
):
self._auto_graph = True
|
offset_code
property
offset_code: Tensor | None
A copy for inspection; provide a code tensor at construction to train it.