PatchTSTOptions<T>
Options & Configuration · AiDotNet.Models.Options
Configuration options for the PatchTST (Patch Time Series Transformer) model.
Inheritance: ModelOptions → PatchTSTOptions<T>
For Beginners
These options control how the PatchTST model behaves:
Key settings:
- PatchSize: How long each “patch” (segment) of time series is.
Smaller patches capture fine details; larger patches capture broader patterns.
- Stride: How much overlap between patches. Equal to PatchSize for no overlap.
- NumLayers: How deep the transformer is. More layers = more capacity but slower.
- NumHeads: Attention heads. More heads can capture different types of patterns.
- ChannelIndependent: Whether to process each variable independently.
Usually True works better for multivariate forecasting.
Default values are from the original PatchTST paper and work well for most datasets.
How It Works
PatchTST divides time series into patches and processes them with a Transformer encoder. This approach has shown state-of-the-art results on long-term forecasting benchmarks.
Reference: Nie et al., “A Time Series is Worth 64 Words: Long-term Forecasting
with Transformers”, ICLR 2023. https://arxiv.org/abs/2211.14730
Constructors
| Constructor | Summary |
|---|---|
PatchTSTOptions() |
Properties
| Property | Summary |
|---|---|
ILossFunction<T> LossFunction { get; set; } |
Gets or sets the loss function for training. |
bool ChannelIndependent { get; set; } |
Gets or sets whether to use channel-independent (CI) mode. |
bool UseInstanceNormalization { get; set; } |
Gets or sets whether to use instance normalization (RevIN). |
bool UsePreNorm { get; set; } |
Gets or sets whether to use pre-norm (LayerNorm before attention/FFN) or post-norm. |
double AttentionDropout { get; set; } |
Gets or sets the attention dropout rate. |
double Dropout { get; set; } |
Gets or sets the dropout rate. |
double LearningRate { get; set; } |
Gets or sets the learning rate. |
int FeedForwardDimension { get; set; } |
Gets or sets the feedforward network dimension. |
int ModelDimension { get; set; } |
Gets or sets the model dimension (embedding size). |
int NumFeatures { get; set; } |
Gets or sets the number of input features. |
int NumHeads { get; set; } |
Gets or sets the number of attention heads. |
int NumLayers { get; set; } |
Gets or sets the number of transformer encoder layers. |
int PatchSize { get; set; } |
Gets or sets the patch size (segment length). |
int PredictionHorizon { get; set; } |
Gets or sets the prediction horizon. |
int SequenceLength { get; set; } |
Gets or sets the input sequence length. |
int Stride { get; set; } |
Gets or sets the stride between consecutive patches. |
Methods
| Method | Summary |
|---|---|
List<string> Validate() |
Validates the options and returns any validation errors. |
int CalculateNumPatches() |
Calculates the number of patches based on sequence length, patch size, and stride. |