gluonts.block.scaler module

class gluonts.block.scaler.MeanScaler(minimum_scale: float = 1e-10, *args, **kwargs)[source]

Bases: gluonts.block.scaler.Scaler

The MeanScaler computes a per-item scale according to the average absolute value over time of each item. The average is computed only among the observed values in the data tensor, as indicated by the second argument. Items with no observed data are assigned a scale based on the global average.

Parameters

minimum_scale – default scale that is used if the time series has only zeros.

compute_scale(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
Parameters
  • F – A module that can either refer to the Symbol API or the NDArray API in MXNet.

  • data – tensor containing the data to be scaled.

  • observed_indicator – observed_indicator: binary tensor with the same shape as data, that has 1 in correspondence of observed data points, and 0 in correspondence of missing data points.

Returns

shape (N, C), computed according to the average absolute value over time of the observed values.

Return type

Tensor

class gluonts.block.scaler.NOPScaler(*args, **kwargs)[source]

Bases: gluonts.block.scaler.Scaler

The NOPScaler assigns a scale equals to 1 to each input item, i.e., no scaling is applied upon calling the NOPScaler.

compute_scale(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
Parameters
  • F – A module that can either refer to the Symbol API or the NDArray API in MXNet.

  • data – tensor containing the data to be scaled.

  • observed_indicator – observed_indicator: binary tensor with the same shape as data, that has 1 in correspondence of observed data points, and 0 in correspondence of missing data points.

Returns

shape (N, C), identically equal to 1.

Return type

Tensor

class gluonts.block.scaler.Scaler(keepdims: bool = False, axis: int = 1)[source]

Bases: mxnet.gluon.block.HybridBlock

Base class for blocks used to scale data.

Parameters
  • keepdims – toggle to keep the dimension of the input tensor.

  • axis – specify the axis over which to scale. Default is 1 for (N, T, C) shaped input tensor.

compute_scale(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]

Computes the scale of the given input data.

Parameters
  • F – A module that can either refer to the Symbol API or the NDArray API in MXNet.

  • data – tensor containing the data to be scaled.

  • observed_indicator – observed_indicator: binary tensor with the same shape as data, that has 1 in correspondence of observed data points, and 0 in correspondence of missing data points.

hybrid_forward(F, data: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], observed_indicator: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]][source]
Parameters
  • F – A module that can either refer to the Symbol API or the NDArray API in MXNet.

  • data – tensor containing the data to be scaled.

  • observed_indicator – observed_indicator: binary tensor with the same shape as data, that has 1 in correspondence of observed data points, and 0 in correspondence of missing data points.

Returns

  • Tensor – Tensor containing the “scaled” data.

  • Tensor – Tensor containing the scale: this has the same shape as the data, except for the axis axis along which the scale is computed, which is removed if keepdims == False, and kept with length 1 otherwise. For example, if data has shape (N, T, C) and axis ==1 ``, then ``scale has shape (N, C) if keepdims == False, and (N, 1, C) otherwise.