Skip to main content
The PatchTST model is an efficient Transformer-based model for multivariate time series forecasting. It is based on two key components: - segmentation of time series into windows (patches) which are served as input tokens to Transformer - channel-independence. where each channel contains a single univariate time series. References Figure 1. PatchTST. Figure 1. PatchTST.

1. PatchTST

PatchTST

Bases: BaseModel PatchTST The PatchTST model is an efficient Transformer-based model for multivariate time series forecasting. It is based on two key components:
  • segmentation of time series into windows (patches) which are served as input tokens to Transformer
  • channel-independence, where each channel contains a single univariate time series.
Parameters:

PatchTST.fit

Fit. The fit method, optimizes the neural network’s weights using the initialization parameters (learning_rate, windows_batch_size, …) and the loss function as defined during the initialization. Within fit we use a PyTorch Lightning Trainer that inherits the initialization’s self.trainer_kwargs, to customize its inputs, see PL’s trainer arguments. The method is designed to be compatible with SKLearn-like classes and in particular to be compatible with the StatsForecast library. By default the model is not saving training checkpoints to protect disk memory, to get them change enable_checkpointing=True in __init__. Parameters: Returns:

PatchTST.predict

Predict. Neural network prediction with PL’s Trainer execution of predict_step. Parameters: Returns:

Usage example

2. Backbone

Auxiliary Functions

get_activation_fn

Transpose

Bases: Module Transpose

Positional Encoding

positional_encoding

Coord1dPosEncoding

Coord2dPosEncoding

PositionalEncoding

Encoder

TSTEncoderLayer

Bases: Module TSTEncoderLayer

TSTEncoder

Bases: Module TSTEncoder

TSTiEncoder

Bases: Module TSTiEncoder

Flatten_Head

Bases: Module Flatten_Head

PatchTST_backbone

Bases: Module PatchTST_backbone