TIDE#

class pytorch_forecasting.models.tide._tide_dsipts._tide_v2.TIDE(metadata: dict, loss: Module, hidden_size: int, d_model: int, n_add_enc: int, n_add_dec: int, dropout_rate: float, activation: str = '', embs: list[int] = [], persistence_weight: float = 0.0, optim: str | None = None, optim_config: dict | None = None, scheduler_config: dict | None = None, **kwargs)[source]#

Bases: BaseModel

Long-term Forecasting with TiDE: Time-series Dense Encoder https://arxiv.org/abs/2304.08424

This NN uses as subnet the ResidualBlocks, which is composed by skip connection and activation+dropout. Every encoder and decoder head is composed by one Residual Block, like the temporal decoder and the feature projection for covariates.

Initialise the model.

Parameters:
  • metadata (dict) – Metadata for the model from EncoderDecoderDataModule. This can include information about the dataset, such as the number of time steps, number of features, etc. It is used to initialize the model and ensure it is compatible with the data being used.

  • loss (nn.Module) – Loss function module (e.g., MSELoss, QuantileLoss).

  • hidden_size (int) – Dimensionality of hidden layers in projections (R).

  • d_model (int) – Dimensionality of model projections after feature projection (R̃).

  • n_add_enc (int) – Number of additional encoder residual blocks (after the first).

  • n_add_dec (int) – Number of additional decoder residual blocks (after the first).

  • dropout_rate (float) – Dropout probability applied in residual blocks.

  • activation (str, optional) – Name of activation function to use (e.g., "relu").

  • embs (list of int, optional) – List specifying embedding sizes for categorical variables.

  • persistence_weight (float, optional) – Weight for the persistence (autoregressive) component.

  • optim (str or None, optional) – Name of optimizer (e.g., "adam"), or None to use default.

  • optim_config (dict or None, optional) – Optimizer configuration dictionary.

  • scheduler_config (dict or None, optional) – Scheduler configuration dictionary.

  • **kwargs – Additional keyword arguments passed to BaseModel.

Methods

cat_categorical_vars(batch)

Extracting categorical context about past and future

forward(X)

training process of the diffusion network

remove_var(tensor, indexes_to_exclude, dimension)

Function to remove variables from tensors in chosen dimension and position

cat_categorical_vars(batch: dict)[source]#

Extracting categorical context about past and future

Parameters:

batch (dict) – dataloader batch

Returns:

cat_emb_past, cat_emb_fut

Return type:

List[torch.Tensor, torch.Tensor]

forward(X: dict) dict[source]#

training process of the diffusion network

Parameters:

X (dict) – variables loaded

Returns:

total loss about the prediction of the noises over all subnets extracted

Return type:

float

remove_var(tensor: Tensor, indexes_to_exclude: list, dimension: int) Tensor[source]#

Function to remove variables from tensors in chosen dimension and position

Parameters:
  • tensor (torch.Tensor) – starting tensor

  • indexes_to_exclude (list) – index of the chosen dimension we want t oexclude

  • dimension (int) – dimension of the tensor on which we want to work (not list od dims!!)

Returns:

new tensor without the chosen variables

Return type:

torch.Tensor