Implementation:Sktime Pytorch forecasting TiDE
| Knowledge Sources | |
|---|---|
| Domains | Time_Series, Forecasting, Deep_Learning |
| Last Updated | 2026-02-08 08:00 GMT |
Overview
TiDE (Time-series Dense Encoder) is an MLP-based encoder-decoder model designed for long-term time series forecasting without attention mechanisms.
Description
TiDEModel extends BaseModelWithCovariates and implements the TiDE architecture, which uses dense residual blocks for encoding and decoding instead of attention-based transformers. The model encodes the flattened historical targets along with projected encoder and decoder covariates through stacked residual blocks, then decodes through additional residual blocks and a temporal decoder. A linear skip connection from lookback targets to future predictions adds a direct autoregressive path. The model supports future covariates, static covariates, and multi-target forecasting, while achieving competitive performance with reduced computational cost compared to transformer-based approaches.
Usage
Use TiDE when you need efficient long-term time series forecasting, particularly when computational resources are limited. It provides transformer-competitive accuracy with MLP-based simplicity. The preferred instantiation method is via from_dataset, which automatically configures input/output dimensions from a TimeSeriesDataSet.
Code Reference
Source Location
- Repository: Sktime_Pytorch_forecasting
- File: pytorch_forecasting/models/tide/_tide.py
- Lines: 1-338
Signature
class TiDEModel(BaseModelWithCovariates):
def __init__(
self,
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: nn.ModuleList = None,
**kwargs,
):
from_dataset Signature
@classmethod
def from_dataset(cls, dataset: TimeSeriesDataSet, **kwargs):
Import
from pytorch_forecasting.models.tide import TiDEModel
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| output_chunk_length | int | Yes | Number of time steps the model predicts simultaneously (horizon). |
| input_chunk_length | int | Yes | Number of past time steps used as input (lookback). |
| num_encoder_layers | int | No | Number of residual blocks in the encoder. Defaults to 2. |
| num_decoder_layers | int | No | Number of residual blocks in the decoder. Defaults to 2. |
| decoder_output_dim | int | No | Dimensionality of the decoder output. Defaults to 16. |
| hidden_size | int | No | Size of hidden layers in encoder/decoder. Defaults to 128. |
| temporal_width_future | int | No | Output width for future covariate projections (0 = bypass). Defaults to 4. |
| temporal_hidden_size_future | int | No | Hidden width for future covariate projections. Defaults to 32. |
| temporal_decoder_hidden | int | No | Width of temporal decoder layers. Defaults to 32. |
| use_layer_norm | bool | No | Whether to apply layer normalization. Defaults to False. |
| dropout | float | No | Dropout probability. Defaults to 0.1. |
| output_size | list[int] | No | Number of outputs per target. Defaults to 1. |
| logging_metrics | nn.ModuleList | No | Metrics for logging. Defaults to [SMAPE, MAE, RMSE, MAPE, MASE]. |
| static_categoricals | None | No | Names of static categorical variables. |
| static_reals | None | No | Names of static continuous variables. |
| embedding_sizes | None | No | Categorical variable embedding sizes. |
Outputs
| Name | Type | Description |
|---|---|---|
| prediction | torch.Tensor | Forecast output transformed to target space, shape (batch_size, output_chunk_length, output_dim) or list of tensors for multi-target. |
Usage Examples
from pytorch_forecasting import TimeSeriesDataSet
from pytorch_forecasting.models.tide import TiDEModel
# Create model from dataset (preferred)
model = TiDEModel.from_dataset(
dataset,
hidden_size=128,
num_encoder_layers=2,
num_decoder_layers=2,
dropout=0.1,
)
# Direct instantiation
model = TiDEModel(
output_chunk_length=24,
input_chunk_length=96,
num_encoder_layers=3,
num_decoder_layers=3,
hidden_size=256,
decoder_output_dim=32,
temporal_width_future=4,
temporal_decoder_hidden=64,
dropout=0.1,
use_layer_norm=True,
)
Related Pages
- Principle:Sktime_Pytorch_forecasting_Dense_Encoder_Decoder
- Sktime_Pytorch_forecasting_TiDE_V2 - V2 implementation of TiDE on the new data pipeline
- Sktime_Pytorch_forecasting_RecurrentNetwork - Alternative recurrent architecture