class_docstr: NLinear module
class_docstr_tok: ["NLinear","module"]
docstr: PyTorch module implementing the N-HiTS architecture.
  
  Parameters
  ----------
  input_dim
      The number of input components (target + optional covariate)
  output_dim
      Number of output components in the target
  future_cov_dim
      Number of components in the future covariates
  static_cov_dim
      Dimensionality of the static covariates (either component-specific or shared)
  nr_params
      The number of parameters of the likelihood (or 1 if no likelihood is used).
  shared_weights
      Whether to use shared weights for the components of the series.
      ** Ignores covariates when True. **
  const_init
      Whether to initialize the weights to 1/in_len
  normalize
      Whether to apply the "normalization" described in the paper.
  
  **kwargs
      all parameters required for :class:`darts.model.forecasting_models.PLForecastingModule` base class.
  
  Inputs
  ------
  x of shape `(batch_size, input_chunk_length)`
      Tensor containing the input sequence.
  
  Outputs
  -------
  y of shape `(batch_size, output_chunk_length, target_size/output_dim, nr_params)`
      Tensor containing the output of the NBEATS module.
docstr_tok: ["PyTorch","module","implementing","the","N-HiTS","architecture",".","Parameters","--","--","--","--","--","input_dim","The","number","of","input","components","(","target","+","optional","covariate",")","output_dim","Number","of","output","components","in","the","target","future_cov_dim","Number","of","components","in","the","future","covariates","static_cov_dim","Dimensionality","of","the","static","covariates","(","either","component-specific","or","shared",")","nr_params","The","number","of","parameters","of","the","likelihood","(","or","1","if","no","likelihood","is","used",")",".","shared_weights","Whether","to","use","shared","weights","for","the","components","of","the","series",".","*","*","Ignores","covariates","when","True",".","*","*","const_init","Whether","to","initialize","the","weights","to","1\/in_len","normalize","Whether","to","apply","the","``","normalization","''","described","in","the","paper",".","*","*","kwargs","all","parameters","required","for",":","class",":","`","darts.model.forecasting_models.PLForecastingModule","`","base","class",".","Inputs","--","--","--","x","of","shape","`","(","batch_size",",","input_chunk_length",")","`","Tensor","containing","the","input","sequence",".","Outputs","--","--","--","-","y","of","shape","`","(","batch_size",",","output_chunk_length",",","target_size\/output_dim",",","nr_params",")","`","Tensor","containing","the","output","of","the","NBEATS","module","."]
code: def __init__(
      self,
      input_dim: int,
      output_dim: int,
      future_cov_dim: int,
      static_cov_dim: int,
      nr_params: int,
      shared_weights: bool,
      const_init: bool,
      normalize: bool,
      **kwargs,
  ):
      """PyTorch module implementing the N-HiTS architecture.
  
      Parameters
      ----------
      input_dim
          The number of input components (target + optional covariate)
      output_dim
          Number of output components in the target
      future_cov_dim
          Number of components in the future covariates
      static_cov_dim
          Dimensionality of the static covariates (either component-specific or shared)
      nr_params
          The number of parameters of the likelihood (or 1 if no likelihood is used).
      shared_weights
          Whether to use shared weights for the components of the series.
          ** Ignores covariates when True. **
      const_init
          Whether to initialize the weights to 1/in_len
      normalize
          Whether to apply the "normalization" described in the paper.
  
      **kwargs
          all parameters required for :class:`darts.model.forecasting_models.PLForecastingModule` base class.
  
      Inputs
      ------
      x of shape `(batch_size, input_chunk_length)`
          Tensor containing the input sequence.
  
      Outputs
      -------
      y of shape `(batch_size, output_chunk_length, target_size/output_dim, nr_params)`
          Tensor containing the output of the NBEATS module.
  
      """
      super().__init__(**kwargs)
      self.input_dim = input_dim
      self.output_dim = output_dim
      self.future_cov_dim = future_cov_dim
      self.static_cov_dim = static_cov_dim
      self.nr_params = nr_params
      self.shared_weights = shared_weights
      self.const_init = const_init
      self.normalize = normalize
  
      def _create_linear_layer(in_dim, out_dim):
          layer = nn.Linear(in_dim, out_dim)
          if self.const_init:
              layer.weight = nn.Parameter(
                  (1.0 / in_dim) * torch.ones(layer.weight.shape)
              )
          return layer
  
      if self.shared_weights:
          layer_in_dim = self.input_chunk_length
          layer_out_dim = self.output_chunk_length * self.nr_params
      else:
          layer_in_dim = self.input_chunk_length * self.input_dim
          layer_out_dim = (
              self.output_chunk_length
              * self.output_dim
              * self.nr_params
          )
  
      self.layer = _create_linear_layer(layer_in_dim, layer_out_dim)
  
      if self.future_cov_dim != 0:
          # future covariates layer acts on time steps independently
          self.linear_fut_cov = _create_linear_layer(
              self.future_cov_dim, self.output_dim * self.nr_params
          )
      if self.static_cov_dim != 0:
          self.linear_static_cov = _create_linear_layer(
              self.static_cov_dim, layer_out_dim
          )
  
file_path: darts/darts/models/forecasting/nlinear.py
imports: from typing import Optional, Tuple
  import torch
  import torch.nn
  from darts.logging import raise_if
  from darts.models.forecasting.pl_forecasting_module import PLMixedCovariatesModule, io_processor
  from darts.models.forecasting.torch_forecasting_model import MixedCovariatesTorchModel
label_desc: Use image node_id 1 to create a new _NLinearModule object from inherited base classes: PLMixedCovariatesModule with example: obj = _NLinearModule(input_dim, output_dim, future_cov_dim, static_cov_dim, nr_params, shared_weights, const_init, normalize)