Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/SforAiDl/lrnnx/llms.txt

Use this file to discover all available pages before exploring further.

LRNN

Base class for all LRNN (Linear Recurrent Neural Network) models. This abstract class provides the foundation for both LTI (Linear Time-Invariant) and LTV (Linear Time-Varying) LRNN implementations.

Class Hierarchy

The LRNN class serves as the parent class for:
  • LTI_LRNN - Linear Time-Invariant LRNN models
  • LTV_LRNN - Linear Time-Varying LRNN models

Constructor

LRNN(discretization)
Initialize the base LRNN model with a specified discretization method.
discretization
Literal['zoh', 'bilinear', 'dirac', 'async', 'no_discretization'] | None
Discretization method to use for converting continuous-time systems to discrete-time:
  • "zoh" - Zero-Order Hold discretization
  • "bilinear" - Bilinear transform method (used in S4)
  • "dirac" - Dirac discretization method
  • "async" - Asynchronous discretization for event-driven models
  • "no_discretization" - Identity operation, no discretization applied
  • None - For models that handle discretization internally

Abstract Methods

forward

forward(x, integration_timesteps=None, lengths=None) -> Tensor
Forward pass through the LRNN. This method must be implemented by all subclasses.
x
torch.Tensor
required
Input tensor, ideally of shape (B, L, H) where:
  • B is the batch size
  • L is the sequence length
  • H is the hidden dimension
integration_timesteps
torch.Tensor
Timesteps for async/event-driven discretization (see arxiv:2404.18508), ideally of shape (B, L). Only applicable for LTV models; LTI models ignore this parameter.
lengths
torch.Tensor
Lengths of sequences, ideally of shape (B,). Required for bidirectional models to properly handle variable-length sequences.
output
torch.Tensor
Output tensor with the same shape as input x, ideally (B, L, H).

Attributes

discretize_fn
Callable | None
The discretization function selected based on the discretization parameter. Set to None if no discretization method is specified.

Example Usage

from lrnnx.core import LRNN

# Note: LRNN is abstract and cannot be instantiated directly
# Create a subclass instance with ZOH discretization
class MyLRNN(LRNN):
    def forward(self, x, integration_timesteps=None, lengths=None):
        # Implementation here
        pass

my_lrnn = MyLRNN("zoh")

See Also

Build docs developers (and LLMs) love