lisbet.modeling.backbones#

class lisbet.modeling.backbones.BackboneInterface(*args, **kwargs)[source]#

Abstract base class for all backbone models.

This interface defines the required methods that all backbone implementations must provide.

abstractmethod forward(x)[source]#

Forward pass through the backbone.

Parameters:

x (Tensor) – Input tensor of shape (batch_size, sequence_length, input_dim).

Returns:

Output tensor of shape (batch_size, sequence_length, output_dim).

Return type:

Tensor

abstractmethod get_config()[source]#

Get the configuration dictionary for this backbone.

Returns:

Configuration dictionary containing all parameters needed to recreate this backbone instance.

Return type:

dict[str, Any]

abstractmethod classmethod from_config(config)[source]#

Create a backbone instance from a configuration dictionary.

Parameters:

config (dict[str, Any]) – Configuration dictionary containing all parameters needed to create the backbone instance.

Returns:

New backbone instance created from the configuration.

Return type:

BackboneInterface

class lisbet.modeling.backbones.TransformerBackbone(feature_dim, embedding_dim, hidden_dim, num_heads, num_layers, max_length)[source]#

Transformer backbone for sequence modeling.

A transformer-based backbone that processes input sequences using self-attention mechanisms. The backbone includes frame embedding, positional embedding, transformer encoder layers, and layer normalization.

Parameters:
  • feature_dim (int) – Dimension of the input features.

  • embedding_dim (int) – Dimension of the output embeddings.

  • hidden_dim (int) – Dimension of the feedforward network inside transformer layers.

  • num_heads (int) – Number of attention heads in the multi-head attention mechanism.

  • num_layers (int) – Number of transformer encoder layers.

  • max_length (int) – Maximum sequence length for positional embeddings.

frame_embedder#

Linear layer for embedding input frames.

Type:

nn.Linear

pos_embedder#

Positional embedding module.

Type:

PosEmbedding

transformer_encoder#

Stack of transformer encoder layers.

Type:

nn.TransformerEncoder

layer_norm#

Layer normalization applied to the output.

Type:

nn.LayerNorm

__init__(feature_dim, embedding_dim, hidden_dim, num_heads, num_layers, max_length)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Forward pass through the transformer backbone.

Parameters:

x (Tensor) – Input tensor of shape (batch_size, sequence_length, feature_dim).

Returns:

Output tensor of shape (batch_size, sequence_length, embedding_dim).

Return type:

Tensor

get_config()[source]#

Get the configuration dictionary for this backbone.

Returns:

Configuration dictionary containing all parameters needed to recreate this backbone instance.

Return type:

dict[str, Any]

classmethod from_config(config)[source]#

Create a TransformerBackbone instance from a configuration dictionary.

Parameters:

config (dict[str, Any]) – Configuration dictionary containing all parameters needed to create the backbone instance.

Returns:

New TransformerBackbone instance created from the configuration.

Return type:

TransformerBackbone

class lisbet.modeling.backbones.LSTMBackbone(feature_dim, embedding_dim, hidden_dim, num_layers)[source]#

LSTM backbone for sequence modeling.

Parameters:
  • feature_dim (int) – Dimension of the input features.

  • embedding_dim (int) – Dimension of the output embeddings.

  • hidden_dim (int) – Dimension of the LSTM hidden state.

  • num_layers (int) – Number of LSTM layers.

__init__(feature_dim, embedding_dim, hidden_dim, num_layers)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Forward pass through the LSTM backbone.

Parameters:

x (Tensor) – Input tensor of shape (batch_size, sequence_length, feature_dim).

Returns:

Output tensor of shape (batch_size, sequence_length, embedding_dim).

Return type:

Tensor

get_config()[source]#

Get the configuration dictionary for this backbone.

Return type:

dict[str, Any]

classmethod from_config(config)[source]#

Create an LSTMBackbone instance from a configuration dictionary.

Return type:

LSTMBackbone

class lisbet.modeling.backbones.TCNBackbone(feature_dim, embedding_dim, hidden_dim, num_layers, kernel_size=3, dilation_base=2, dropout=0.0)[source]#

Temporal Convolutional Network (TCN) backbone for sequence modeling.

Parameters:
  • feature_dim (int) – Dimension of the input features.

  • embedding_dim (int) – Dimension of the output embeddings.

  • hidden_dim (int) – Number of channels in the hidden layers.

  • num_layers (int) – Number of temporal blocks (layers).

  • kernel_size (int) – Size of the convolutional kernel. Default: 3

  • dilation_base (int) – Base for the dilation factor. Default: 2

  • dropout (float) – Dropout rate. Default: 0.0

__init__(feature_dim, embedding_dim, hidden_dim, num_layers, kernel_size=3, dilation_base=2, dropout=0.0)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Forward pass through the TCN backbone.

Parameters:

x (Tensor) – Input tensor of shape (batch_size, sequence_length, feature_dim).

Returns:

Output tensor of shape (batch_size, sequence_length, embedding_dim).

Return type:

Tensor

get_config()[source]#

Get the configuration dictionary for this backbone.

Return type:

dict[str, Any]

classmethod from_config(config)[source]#

Create a TCNBackbone instance from a configuration dictionary.

Return type:

TCNBackbone

Modules

base

Abstract base class for backbone models.

lstm

LSTM Backbone for LISBET.

tcn

TCN Backbone for LISBET.

transformer

Transformer Backbone for Lisbet.