xLSTMTime#

class pytorch_forecasting.models.xlstm._xlstm.xLSTMTime(input_size: int, hidden_size: int, output_size: int, xlstm_type: Literal['slstm', 'mlstm'] = 'slstm', num_layers: int = 1, decomposition_kernel: int = 25, input_projection_size: int | None = None, dropout: float = 0.1, loss: Metric = SMAPE(), **kwargs)[source]#

Bases: AutoRegressiveBaseModel

xLSTMTime is a long‑term time series forecasting architecture built on the extended LSTM (xLSTM) design, incorporating either the scalar-memory stabilized LSTM (sLSTM) or the matrix-memory mLSTM variant. This model enhances classical LSTM by adding exponential gating and richer memory dynamics, and combines series decomposition and normalization layers to produce robust forecasts over extended horizons.

It is based on this paper: https://arxiv.org/pdf/2407.10240 and https://github.com/muslehal/xLSTMTime

Initialise the model.

Parameters:
  • input_size (int) – Number of input continuous features per time step.

  • hidden_size (int) – Hidden size of the xLSTM network; also used by batch norm / LSTM internals.

  • output_size (int) – Number of output features per time step (forecast horizon).

  • xlstm_type ({"slstm", "mlstm"}, default "slstm") – Specifies which xLSTM variant to use: - “slstm”: stabilized LSTM with scalar memory, - “mlstm”: matrix-memory variant for higher capacity and scalability.

  • num_layers (int, default 1) – Number of recurrent layers in the sLSTM or mLSTM network.

  • decomposition_kernel (int, default 25) – Kernel size for series decomposition into trend and seasonal components.

  • input_projection_size (int, optional) – If specified, the encoded input (trend + seasonal) is projected to this size before being fed to the xLSTM; otherwise equals hidden_size.

  • dropout (float, default 0.1) – Dropout rate applied within the recurrent layers.

  • loss (pytorch_forecasting.metrics.Metric, default SMAPE()) – Loss (and evaluation metric) used during training.

Methods

forward(x[, hidden_states])

Forward Pass for the model.

from_dataset(dataset, **kwargs)

Create model from dataset and set parameters related to covariates.

classmethod from_dataset(dataset, **kwargs)[source]#

Create model from dataset and set parameters related to covariates.

Parameters:
  • dataset (timeseries dataset)

  • **kwargs (additional arguments such as hyperparameters for model)

Return type:

xLSTMTime

forward(x: dict[str, Tensor], hidden_states: tuple[Tensor, Tensor] | tuple[Tensor, Tensor, Tensor] | None = None) dict[str, Tensor][source]#

Forward Pass for the model.