gluonts.torch.model.i_transformer.module module#

class gluonts.torch.model.i_transformer.module.ITransformerModel(prediction_length: int, context_length: int, d_model: int, nhead: int, dim_feedforward: int, dropout: float, activation: str, norm_first: bool, num_encoder_layers: int, scaling: Optional[str], distr_output=gluonts.torch.distributions.studentT.StudentTOutput(beta=0.0), nonnegative_pred_samples: bool = False)[source]#

Bases: torch.nn.modules.module.Module

Module implementing the iTransformer model for multivariate forecasting as described in https://arxiv.org/abs/2310.06625 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.

  • d_model – Transformer latent dimension.

  • nhead – Number of attention heads which must be divisible with d_model.

  • dim_feedforward – Dimension of the transformer’s feedforward network model.

  • dropout – Dropout rate for the transformer.

  • activation – Activation function for the transformer.

  • norm_first – Whether to normalize the input before the transformer.

  • num_encoder_layers – Number of transformer encoder layers.

  • scaling – Whether to scale the input using mean or std or None.

  • distr_output – Distribution to use to evaluate observations and sample predictions. Default: StudentTOutput().

  • nonnegative_pred_samples – Should final prediction samples be non-negative? If yes, an activation function is applied to ensure non-negative. Observe that this is applied only to the final samples and this is not applied during training.

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#