TiDEModel#
- class pytorch_forecasting.models.tide._tide.TiDEModel(output_chunk_length: int, input_chunk_length: int, num_encoder_layers: int = 2, num_decoder_layers: int = 2, decoder_output_dim: int = 16, hidden_size: int = 128, temporal_width_future: int = 4, temporal_hidden_size_future: int = 32, temporal_decoder_hidden: int = 32, use_layer_norm: bool = False, dropout: float = 0.1, output_size: int | list[int] = 1, static_categoricals: list[str] | None = None, static_reals: list[str] | None = None, time_varying_categoricals_encoder: list[str] | None = None, time_varying_categoricals_decoder: list[str] | None = None, categorical_groups: dict[str, list[str]] | None = None, time_varying_reals_encoder: list[str] | None = None, time_varying_reals_decoder: list[str] | None = None, embedding_sizes: dict[str, tuple[int, int]] | None = None, embedding_paddings: list[str] | None = None, embedding_labels: list[str] | None = None, x_reals: list[str] | None = None, x_categoricals: list[str] | None = None, logging_metrics: ModuleList = None, **kwargs)[source]#
Bases:
BaseModelWithCovariatesTiDE model for long-term time-series forecasting.
An implementation of the TiDE model.
TiDE shares similarities with Transformers (implemented in :class:TransformerModel), but aims to deliver better performance with reduced computational requirements by utilizing MLP-based encoder-decoder architectures without attention mechanisms.
This model supports future covariates (known for output_chunk_length points after the prediction time) andstatic covariates.
The encoder and decoder are constructed using residual blocks. The number of residual blocks in the encoder and decoder can be specified with num_encoder_layers and num_decoder_layers respectively. The layer width in the residual blocks can be adjusted using hidden_size, while the layer width in the temporal decoder can be controlled via temporal_decoder_hidden.
- Parameters:
input_chunk_length (int) – Number of past time steps to use as input for themodel (per chunk). This applies to the target series and future covariates (if supported by the model).
output_chunk_length (int) – Number of time steps the internal model predicts simultaneously (per chunk). This also determines how many future values from future covariates are used as input (if supported by the model).
num_encoder_layers (int, default=2) – Number of residual blocks in the encoder
num_decoder_layers (int, default=2) – Number of residual blocks in the decoder
decoder_output_dim (int, default=16) – Dimensionality of the decoder’s output
hidden_size (int, default=128) – Size of hidden layers in the encoder and decoder. Typically ranges from 32 to 128 when no covariates are used.
(int) (temporal_decoder_hidden) – If set to 0, bypasses feature projection and uses raw feature data. Defaults to 4.
(int) – projections. Defaults to 32.
(int)
(bool) (use_layer_norm)
(float) (dropout)
output_size (Union[int, List[int]]: included as its required by deduce_default_output_parameters in) – from_dataset function. Defaults to 1.
(List[str]) (embedding_paddings)
(List[str])
(List[str])
(List[str])
(List[str])
(List[str])
(List[str])
(List[str])
(Dict[str (categorical_groups) – where the first integer denotes the number of categorical classes and the second the embedding size
Tuple[int (dictionary mapping categorical variables to tuple of integers) – where the first integer denotes the number of categorical classes and the second the embedding size
int]]) (dictionary mapping categorical variables to tuple of integers) – where the first integer denotes the number of categorical classes and the second the embedding size
(Dict[str
List[str]]) (dictionary of categorical variables that are grouped together and)
(List[str]) – embedding vector filled with zeros
(Dict[str – can also take multiple values simultaneously (e.g. holiday during octoberfest). They should be implemented as bag of embeddings
List[str]]) – can also take multiple values simultaneously (e.g. holiday during octoberfest). They should be implemented as bag of embeddings
(nn.ModuleList[MultiHorizonMetric]) (logging_metrics) – Defaults to nn.ModuleList([SMAPE(), MAE(), RMSE(), MAPE(), MASE()])
**kwargs – Allows optional arguments to configure pytorch_lightning.Module, pytorch_lightning.Trainer, and pytorch-forecasting’s :class:BaseModelWithCovariates.
Note – The model supports future covariates and static covariates.
Methods
forward(x)Pass forward of network.
from_dataset(dataset, **kwargs)Convenience function to create network from :py:class`~pytorch_forecasting.data.timeseries.TimeSeriesDataSet`.
- classmethod from_dataset(dataset: TimeSeriesDataSet, **kwargs)[source]#
Convenience function to create network from :py:class`~pytorch_forecasting.data.timeseries.TimeSeriesDataSet`.
- Parameters:
dataset (TimeSeriesDataSet) – dataset where sole predictor is the target.
**kwargs – additional arguments to be passed to __init__ method.
- Returns:
TiDE
- forward(x: dict[str, Tensor]) dict[str, Tensor][source]#
Pass forward of network.
- Parameters:
x (Dict[str, torch.Tensor]) – input from dataloader generated from :py:class:~pytorch_forecasting.data.timeseries.TimeSeriesDataSet.
- Returns:
output of model
- Return type:
Dict[str, torch.Tensor]
- property decoder_covariate_size: int#
Decoder covariates size.
- Returns:
size of time-dependent covariates used by the decoder
- Return type:
int
- property encoder_covariate_size: int#
Encoder covariate size.
- Returns:
size of time-dependent covariates used by the encoder
- Return type:
int
- property static_size: int#
Static covariate size.
- Returns:
size of static covariates
- Return type:
int