lrnnx.core.base module

Base Model class for LRNNX.

class LRNN[source]

Bases: Module

__init__(discretization: Literal['zoh', 'bilinear', 'dirac', 'async', 'no_discretization'] | None)[source]

Initialize the base LRNN model.

Parameters:

discretization (Optional[Literal]) – Discretization method to use, can be one of: - “zoh” for Zero-Order Hold - “bilinear” for Bilinear method - “dirac” for Dirac method - “async” for asynchronous discretization - “no_discretization” for no discretization - None for models that handle discretization internally

Each model must have a usage example in the documentation, like so:

>>> from lrnnx.core import LRNN
>>> my_lrnn = LRNN("zoh")
>>> # create dummy input tensor and perform forward pass
>>> # in subclass
abstractmethod forward(x: torch.Tensor, integration_timesteps: torch.Tensor | None = None, lengths: torch.Tensor | None = None) torch.Tensor[source]

Forward pass of through the LRNN.

Parameters:
  • x (torch.Tensor) – Input tensor, ideally of shape (B, L, H).

  • integration_timesteps (torch.Tensor, optional) – Timesteps for async/event-driven discretization (Reference: https://arxiv.org/abs/2404.18508), ideally of shape (B, L). Only applicable for LTV models; LTI models ignore this parameter. Defaults to None.

  • lengths (torch.Tensor, optional) – Lengths of sequences, ideally of shape (B,), this is required for bidirectional models. Defaults to None.

Returns:

Output tensor, same shape as input (x), ideally (B, L, H).

Return type:

torch.Tensor