dsipts.models.Informer module

class dsipts.models.Informer.Informer(past_steps, future_steps, past_channels, future_channels, d_model, embs, hidden_size, n_layer_encoder, n_layer_decoder, out_channels, mix=True, activation='torch.nn.ReLU', remove_last=False, attn='prob', distil=True, factor=5, n_head=1, persistence_weight=0.0, loss_type='l1', quantiles=[], dropout_rate=0.1, optim=None, optim_config=None, scheduler_config=None, **kwargs)[source]

Bases: Base

Parameters:
  • past_steps (int) – number of past datapoints used , not used here

  • future_steps (int) – number of future lag to predict

  • past_channels (int) – number of numeric past variables, must be >0

  • future_channels (int) – number of future numeric variables

  • d_model (int) – dimension of the attention model

  • embs (List) – list of the initial dimension of the categorical variables

  • hidden_size (int) – hidden size of the linear block

  • n_layer_encoder (int) – layers to use in the encoder

  • n_layer_decoder (int) – layers to use in the decoder

  • out_channels (int) – number of output channels

  • mix (bool, optional) – se mix attention in generative decoder. Defaults to True.

  • activation (str, optional) – relu or gelu. Defaults to ‘relu’.

  • remove_last (boolean,optional) – if true the model try to predic the difference respect the last observation.

  • attn (str, optional) – attention used in encoder, options:[prob, full]. Defaults to ‘prob’.

  • distil (bool, optional) – whether to use distilling in encoder, using this argument means not using distilling. Defaults to True.

  • factor (int, optional) – probsparse attn factor. Defaults to 5.

  • n_head (int, optional) – heads equal in the encoder and encoder. Defaults to 1.

  • persistence_weight (float) – weight controlling the divergence from persistence model. Default 0

  • loss_type (str, optional) – this model uses custom losses or l1 or mse. Custom losses can be linear_penalization or exponential_penalization. Default l1,

  • quantiles (List[int], optional) – NOT USED YET

  • dropout_rate (float, optional) – dropout rate in Dropout layers. Defaults to 0.1.

  • optim (str, optional) – if not None it expects a pytorch optim method. Defaults to None that is mapped to Adam.

  • optim_config (dict, optional) – configuration for Adam optimizer. Defaults to None.

  • scheduler_config (dict, optional) – configuration for stepLR scheduler. Defaults to None.

handle_multivariate = True
handle_future_covariates = True
handle_categorical_variables = True
handle_quantile_loss = True
description = 'Can   handle multivariate output \nCan   handle future covariates\nCan   handle categorical covariates\nCan   handle Quantile loss function'
__init__(past_steps, future_steps, past_channels, future_channels, d_model, embs, hidden_size, n_layer_encoder, n_layer_decoder, out_channels, mix=True, activation='torch.nn.ReLU', remove_last=False, attn='prob', distil=True, factor=5, n_head=1, persistence_weight=0.0, loss_type='l1', quantiles=[], dropout_rate=0.1, optim=None, optim_config=None, scheduler_config=None, **kwargs)[source]

Informer

Parameters:
  • past_steps (int) – number of past datapoints used , not used here

  • future_steps (int) – number of future lag to predict

  • past_channels (int) – number of numeric past variables, must be >0

  • future_channels (int) – number of future numeric variables

  • d_model (int) – dimension of the attention model

  • embs (List) – list of the initial dimension of the categorical variables

  • hidden_size (int) – hidden size of the linear block

  • n_layer_encoder (int) – layers to use in the encoder

  • n_layer_decoder (int) – layers to use in the decoder

  • out_channels (int) – number of output channels

  • mix (bool, optional) – se mix attention in generative decoder. Defaults to True.

  • activation (str, optional) – relu or gelu. Defaults to ‘relu’.

  • remove_last (boolean,optional) – if true the model try to predic the difference respect the last observation.

  • attn (str, optional) – attention used in encoder, options:[prob, full]. Defaults to ‘prob’.

  • distil (bool, optional) – whether to use distilling in encoder, using this argument means not using distilling. Defaults to True.

  • factor (int, optional) – probsparse attn factor. Defaults to 5.

  • n_head (int, optional) – heads equal in the encoder and encoder. Defaults to 1.

  • persistence_weight (float) – weight controlling the divergence from persistence model. Default 0

  • loss_type (str, optional) – this model uses custom losses or l1 or mse. Custom losses can be linear_penalization or exponential_penalization. Default l1,

  • quantiles (List[int], optional) – NOT USED YET

  • dropout_rate (float, optional) – dropout rate in Dropout layers. Defaults to 0.1.

  • optim (str, optional) – if not None it expects a pytorch optim method. Defaults to None that is mapped to Adam.

  • optim_config (dict, optional) – configuration for Adam optimizer. Defaults to None.

  • scheduler_config (dict, optional) – configuration for stepLR scheduler. Defaults to None.

forward(batch)[source]

Forlward method used during the training loop

Parameters:

batch (dict) – the batch structure. The keys are: y : the target variable(s). This is always present x_num_past: the numerical past variables. This is always present x_num_future: the numerical future variables x_cat_past: the categorical past variables x_cat_future: the categorical future variables idx_target: index of target features in the past array

Returns:

output of the mode;

Return type:

torch.tensor