gluonts.torch.model.patch_tst.module module#
- class gluonts.torch.model.patch_tst.module.PatchTSTModel(prediction_length: int, context_length: int, patch_len: int, stride: int, padding_patch: str, d_model: int, nhead: int, dim_feedforward: int, dropout: float, activation: str, norm_first: bool, num_encoder_layers: int, scaling: str, distr_output=gluonts.torch.distributions.studentT.StudentTOutput(beta=0.0))[source]#
Bases:
torch.nn.modules.module.Module
Module implementing the PatchTST model for forecasting as described in https://arxiv.org/abs/2211.14730 extended to be probabilistic.
- Parameters
prediction_length – Number of time points to predict.
context_length – Number of time steps prior to prediction time that the model.
distr_output – Distribution to use to evaluate observations and sample predictions. Default:
StudentTOutput()
.
- describe_inputs(batch_size=1) gluonts.model.inputs.InputSpec [source]#
- forward(past_target: torch.Tensor, past_observed_values: torch.Tensor) Tuple[Tuple[torch.Tensor, ...], torch.Tensor, torch.Tensor] [source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- loss(past_target: torch.Tensor, past_observed_values: torch.Tensor, future_target: torch.Tensor, future_observed_values: torch.Tensor) torch.Tensor [source]#
- training: bool#
- class gluonts.torch.model.patch_tst.module.SinusoidalPositionalEmbedding(num_positions: int, embedding_dim: int)[source]#
Bases:
torch.nn.modules.sparse.Embedding
This module produces sinusoidal positional embeddings of any length.
- embedding_dim: int#
- forward(input_ids_shape: torch.Size, past_key_values_length: int = 0) torch.Tensor [source]#
input_ids_shape is expected to be [bsz x seqlen x …].
- freeze: bool#
- max_norm: Optional[float]#
- norm_type: float#
- num_embeddings: int#
- padding_idx: Optional[int]#
- scale_grad_by_freq: bool#
- sparse: bool#
- training: bool#
- weight: torch.Tensor#