|
| 1 | +""" |
| 2 | +Implements the TiDE (Time-series Dense Encoder-decoder) model, which is designed for |
| 3 | +long-term time-series forecasting. |
| 4 | +""" |
| 5 | + |
1 | 6 | from copy import copy |
2 | 7 | from typing import Dict, List, Optional, Tuple, Union |
3 | 8 |
|
@@ -44,30 +49,39 @@ def __init__( |
44 | 49 | ): |
45 | 50 | """An implementation of the TiDE model. |
46 | 51 |
|
47 | | - TiDE shares similarities with Transformers (implemented in :class:TransformerModel), but aims to deliver |
48 | | - better performance with reduced computational requirements by utilizing MLP-based encoder-decoder architectures |
49 | | - without attention mechanisms. |
| 52 | + TiDE shares similarities with Transformers |
| 53 | + (implemented in :class:TransformerModel), but aims to deliver better performance |
| 54 | + with reduced computational requirements by utilizing MLP-based encoder-decoder |
| 55 | + architectures without attention mechanisms. |
50 | 56 |
|
51 | | - This model supports future covariates (known for output_chunk_length points after the prediction time) and |
52 | | - static covariates. |
| 57 | + This model supports future covariates (known for output_chunk_length points |
| 58 | + after the prediction time) andstatic covariates. |
53 | 59 |
|
54 | | - The encoder and decoder are constructed using residual blocks. The number of residual blocks in the encoder and |
55 | | - decoder can be specified with `num_encoder_layers` and `num_decoder_layers` respectively. The layer width in the |
56 | | - residual blocks can be adjusted using `hidden_size`, while the layer width in the temporal decoder can be |
57 | | - controlled via `temporal_decoder_hidden`. |
| 60 | + The encoder and decoder are constructed using residual blocks. The number of |
| 61 | + residual blocks in the encoder and decoder can be specified with |
| 62 | + `num_encoder_layers` and `num_decoder_layers` respectively. The layer width in |
| 63 | + the residual blocks can be adjusted using `hidden_size`, while the layer width |
| 64 | + in the temporal decoder can be controlled via `temporal_decoder_hidden`. |
58 | 65 |
|
59 | 66 | Parameters |
60 | 67 | ---------- |
61 | | - input_chunk_length (int): Number of past time steps to use as input for the model (per chunk). |
62 | | - This applies to the target series and future covariates (if supported by the model). |
63 | | - output_chunk_length (int): Number of time steps the internal model predicts simultaneously (per chunk). |
64 | | - This also determines how many future values from future covariates are used as input |
| 68 | + input_chunk_length :int |
| 69 | + Number of past time steps to use as input for themodel (per chunk). |
| 70 | + This applies to the target series and future covariates |
65 | 71 | (if supported by the model). |
66 | | - num_encoder_layers (int): Number of residual blocks in the encoder. Defaults to 2. |
67 | | - num_decoder_layers (int): Number of residual blocks in the decoder. Defaults to 2. |
68 | | - decoder_output_dim (int): Dimensionality of the decoder's output. Defaults to 16. |
69 | | - hidden_size (int): Size of hidden layers in the encoder and decoder. Typically ranges from 32 to 128 when |
70 | | - no covariates are used. Defaults to 128. |
| 72 | + output_chunk_length : int |
| 73 | + Number of time steps the internal model predicts simultaneously (per chunk). |
| 74 | + This also determines how many future values from future covariates |
| 75 | + are used as input (if supported by the model). |
| 76 | + num_encoder_layers : int, default=2 |
| 77 | + Number of residual blocks in the encoder |
| 78 | + num_decoder_layers : int, default=2 |
| 79 | + Number of residual blocks in the decoder |
| 80 | + decoder_output_dim : int, default=16 |
| 81 | + Dimensionality of the decoder's output |
| 82 | + hidden_size : int, default=128 |
| 83 | + Size of hidden layers in the encoder and decoder. |
| 84 | + Typically ranges from 32 to 128 when no covariates are used. |
71 | 85 | temporal_width_future (int): Width of the output layer in the residual block for future covariate projections. |
72 | 86 | If set to 0, bypasses feature projection and uses raw feature data. Defaults to 4. |
73 | 87 | temporal_hidden_size_future (int): Width of the hidden layer in the residual block for future covariate |
@@ -98,8 +112,10 @@ def __init__( |
98 | 112 | **kwargs |
99 | 113 | Allows optional arguments to configure pytorch_lightning.Module, pytorch_lightning.Trainer, and |
100 | 114 | pytorch-forecasting's :class:BaseModelWithCovariates. |
101 | | - """ # noqa: E501 |
102 | 115 |
|
| 116 | + Note: |
| 117 | + The model supports future covariates and static covariates. |
| 118 | + """ # noqa: E501 |
103 | 119 | if static_categoricals is None: |
104 | 120 | static_categoricals = [] |
105 | 121 | if static_reals is None: |
@@ -200,15 +216,16 @@ def static_size(self) -> int: |
200 | 216 | @classmethod |
201 | 217 | def from_dataset(cls, dataset: TimeSeriesDataSet, **kwargs): |
202 | 218 | """ |
203 | | - Convenience function to create network from :py:class`~pytorch_forecasting.data.timeseries.TimeSeriesDataSet`. |
| 219 | + Convenience function to create network from |
| 220 | + :py:class`~pytorch_forecasting.data.timeseries.TimeSeriesDataSet`. |
204 | 221 |
|
205 | 222 | Args: |
206 | 223 | dataset (TimeSeriesDataSet): dataset where sole predictor is the target. |
207 | 224 | **kwargs: additional arguments to be passed to `__init__` method. |
208 | 225 |
|
209 | 226 | Returns: |
210 | 227 | TiDE |
211 | | - """ # noqa: E501 |
| 228 | + """ |
212 | 229 |
|
213 | 230 | # validate arguments |
214 | 231 | assert not isinstance( |
|
0 commit comments