paddlets.models.forecasting.dl.nbeats

This implementation is based on the article N-BEATS: Neural basis expansion analysis for interpretable time series forecasting .

Base model features

Basic architecture: A network with hierarchical stacking, bi-directional residual connection and interpretable generator.

Hierarchical stacking: The Design of multi-stacks with multi-blocks in each is for different kinds of information extraction, ie, trend, seasonality, etc..

Bi-directional residual cascade: The backward residual connection is for computing of the residual signal, and pass the residual to the next layer; the forward residual connection is for accumulating all layers’ forecasts to the final output.

Updated features

Multi-target: support multi-target modelling.

Covariates: support known covariates(future known covariates) and observed covariates(future unknown covariates).

class NBEATSModel(in_chunk_len: int, out_chunk_len: int, generic_architecture: bool = True, num_stacks: int = 2, num_blocks: ~typing.Union[int, ~typing.List[int]] = 3, num_layers: int = 4, layer_widths: ~typing.Union[int, ~typing.List[int]] = 128, expansion_coefficient_dim: int = 128, trend_polynomial_degree: int = 4, skip_chunk_len: int = 0, sampling_stride: int = 1, loss_fn: ~typing.Callable[[...], ~paddle.Tensor] = <function mse_loss>, optimizer_fn: ~typing.Callable[[...], ~paddle.optimizer.optimizer.Optimizer] = <class 'paddle.optimizer.adam.Adam'>, optimizer_params: ~typing.Dict[str, ~typing.Any] = {'learning_rate': 0.0001}, eval_metrics: ~typing.List[str] = [], callbacks: ~typing.List[~paddlets.models.common.callbacks.callbacks.Callback] = [], batch_size: int = 32, max_epochs: int = 10, verbose: int = 1, patience: int = 10, seed: int = 0)[source]

Bases: PaddleBaseModelImpl

Implementation of NBeats model.

Parameters
  • in_chunk_len (int) – The size of the loopback window, i.e., the number of time steps feed to the model.

  • out_chunk_len (int) – The size of the forecasting horizon, i.e., the number of time steps output by the model.

  • generic_architecture (bool, Optional) – Boolean value indicating whether the generic architecture of N-BEATS is used. If not, the interpretable architecture outlined in the paper (consisting of one trend and one seasonality stack with appropriate waveform generator functions).

  • num_stacks (int, Optional) – The number of stacks that make up the whole model. Only used if generic_architecture is set to True.

  • num_blocks (Union[int, List[int]], Optional) – The number of blocks making up each stack. If a list is passed, it must have a length equal to num_stacks and every entry in that list corresponds to the corresponding stack. If an integer is passed, every stack will have the same number of blocks.

  • num_layers (int, Optional) – The number of fully connected layers preceding the final forking layers in each block of every stack. Only used if generic_architecture is set to True.

  • layer_widths (Union[int, List[int]], Optional) – Determines the number of neurons that make up each fully connected layer in each block of every stack. If a list is passed, it must have a length equal to num_stacks and every entry in that list corresponds to the layer width of the corresponding stack. If an integer is passed, every stack will have blocks with FC layers of the same width.

  • expansion_coefficient_dim (int, Optional) – The dimensionality of the waveform generator parameters, also known as expansion coefficients. Only used if generic_architecture is set to True.

  • trend_polynomial_degree (int, Optional) – The degree of the polynomial used as waveform generator in trend stacks. Only used if generic_architecture is set to False.

  • skip_chunk_len (int, Optional) – Optional, the number of time steps between in_chunk and out_chunk for a single sample. The skip chunk is neither used as a feature (i.e. X) nor a label (i.e. Y) for a single sample. By default it will NOT skip any time steps.

  • sampling_stride (int, optional) – sampling intervals between two adjacent samples.

  • loss_fn (Callable, Optional) – loss function.

  • optimizer_fn (Callable, Optional) – optimizer algorithm.

  • optimizer_params (Dict, Optional) – optimizer parameters.

  • eval_metrics (List[str], Optional) – evaluation metrics of model.

  • callbacks (List[Callback], Optional) – customized callback functions.

  • batch_size (int, Optional) – number of samples per batch.

  • max_epochs (int, Optional) – max epochs during training.

  • verbose (int, Optional) – verbosity mode.

  • patience (int, Optional) – number of epochs with no improvement after which learning rate wil be reduced.

  • seed (int, Optional) – global random seed.