paddlets.models.forecasting.dl.nhits

This implementation is based on the article N-HiTS: Neural Hierarchical Interpolation for Time Series Forecasting .

class NHiTSModel(in_chunk_len: int, out_chunk_len: int, num_stacks: int = 3, num_blocks: int = 3, num_layers: int = 2, layer_widths: ~typing.Union[int, ~typing.List[int]] = 512, pooling_kernel_sizes: ~typing.Optional[~typing.Tuple[~typing.Tuple[int]]] = None, n_freq_downsample: ~typing.Optional[~typing.Tuple[~typing.Tuple[int]]] = None, batch_norm: bool = False, dropout: float = 0.1, activation: str = 'ReLU', MaxPool1d: bool = True, 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 = 256, max_epochs: int = 10, verbose: int = 1, patience: int = 4, seed: int = 0)[source]

Bases: PaddleBaseModelImpl

Implementation of NHiTS 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.

  • num_stacks – The number of stacks that make up the whole model.

  • num_blocks – The number of blocks making up every stack.

  • num_layers – The number of fully connected layers preceding the final forking layers in each block of every stack.

  • layer_widths – 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.

  • pooling_kernel_size (Tuple[Tuple[int]], option) – The kernel size for the initial pooling layer.

  • n_freq_downsample (Tuple[Tuple[int]], option) – The factor by which to downsample time at the output (before interpolating).

  • batch_norm (bool) – Whether to use batch normalization.

  • dropout (float) – Dropout probability.

  • activation (str) – The activation function of encoder/decoder intermediate layer.

  • MaxPool1d (bool) – Whether to use MaxPool1d pooling, False uses AvgPool1d.

  • 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.