gluonts.mx.kernels package#

class gluonts.mx.kernels.Kernel[source]#

Bases: object

kernel_matrix(x1: Union[NDArray, Symbol], x2: Union[NDArray, Symbol])[source]#
class gluonts.mx.kernels.KernelOutput[source]#

Bases: object

Class to connect a network to a kernel.

static compute_std(F, data: Union[NDArray, Symbol], axis: int) Union[NDArray, Symbol][source]#

This function computes the standard deviation of the data along a given axis.

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

  • data (Tensor) – Data to be used to compute the standard deviation.

  • axis (int) – Axis along which to compute the standard deviation.

Returns:

The standard deviation of the given data.

Return type:

Tensor

get_args_proj(float_type: Type) HybridBlock[source]#
kernel(args) Kernel[source]#
class gluonts.mx.kernels.KernelOutputDict[source]#

Bases: KernelOutput

args_dim: Dict[str, int]#
domain_map(F, *args: Union[NDArray, Symbol])[source]#
get_args_proj(float_type: ~typing.Type = <class 'numpy.float32'>) ArgProj[source]#

This method calls the ArgProj block in distribution_output to project from a dense layer to kernel arguments.

Parameters:

float_type (Type) – Determines whether to use single or double precision.

Return type:

ArgProj

get_num_args() int[source]#
gp_params_scaling(F, past_target: Union[NDArray, Symbol], past_time_feat: Union[NDArray, Symbol]) tuple[source]#
kernel(kernel_args) Kernel[source]#
Parameters:

kernel_args – Variable length argument list.

Returns:

Instantiated specified Kernel subclass object.

Return type:

gluonts.mx.kernels.Kernel

kernel_cls: type#
class gluonts.mx.kernels.PeriodicKernel(amplitude: Union[NDArray, Symbol], length_scale: Union[NDArray, Symbol], frequency: Union[NDArray, Symbol], F=None)[source]#

Bases: Kernel

Computes a covariance matrix based on the Periodic kernel between inputs \(\mathbf{x_1}\) and \(\mathbf{x_2}\): \(k_{\text{Per}}(\mathbf{x_1}, \mathbf{x_2}) = \theta_0 \exp \left (\frac{-2\sin^2(\theta_2 \pi \|\mathbf{x_1} - \mathbf{x_2}\|)} {\theta_1^2} \right)\), where \(\theta_0\) is the amplitude parameter, \(\theta_1\) is the length scale parameter and \(\theta_2\) is the frequency parameter.

kernel_matrix(x1: Union[NDArray, Symbol], x2: Union[NDArray, Symbol]) Union[NDArray, Symbol][source]#
Parameters:
  • x1 (Tensor) – Feature data of shape (batch_size, history_length, num_features).

  • x2 (Tensor) – Feature data of shape (batch_size, history_length, num_features).

Returns:

Periodic kernel matrix of shape (batch_size, history_length, history_length).

Return type:

Tensor

class gluonts.mx.kernels.PeriodicKernelOutput[source]#

Bases: KernelOutputDict

args_dim: Dict[str, int] = {'amplitude': 1, 'frequency': 1, 'length_scale': 1}#
classmethod domain_map(F, amplitude, length_scale, frequency)[source]#

This function applies the softmax to the Periodic Kernel hyper- parameters.

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

  • amplitude – Periodic kernel amplitude hyper-parameter of shape (batch_size, 1, 1).

  • length_scale – Periodic kernel length scale hyper-parameter of of shape (batch_size, 1, 1).

  • frequency – Periodic kernel hyper-parameter of shape (batch_size, 1, 1).

Returns:

Three GP Periodic kernel hyper-parameters. Each is a Tensor of shape: (batch_size, 1, 1).

Return type:

Tuple[Tensor, Tensor, Tensor]

gp_params_scaling(F, past_target: Union[NDArray, Symbol], past_time_feat: Union[NDArray, Symbol]) Tuple[Union[NDArray, Symbol], Union[NDArray, Symbol], Union[NDArray, Symbol], Union[NDArray, Symbol]][source]#

This function returns the scales for the GP Periodic Kernel hyper- parameters by using the standard deviations of the past_target and past_time_features.

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

  • past_target (Tensor) – Training time series values of shape (batch_size, context_length).

  • past_time_feat (Tensor) – Training features of shape (batch_size, context_length, num_features).

Returns:

Three scaled GP hyper-parameters for the Periodic Kernel and scaled model noise hyper-parameter. Each is a Tensor of shape (batch_size, 1, 1).

Return type:

Tuple

kernel_cls#

alias of PeriodicKernel

class gluonts.mx.kernels.RBFKernel(amplitude: Union[NDArray, Symbol], length_scale: Union[NDArray, Symbol], F=None)[source]#

Bases: Kernel

Computes a covariance matrix based on the RBF (squared exponential) kernel between inputs \(\mathbf{x_1}\) and \(\mathbf{x_2}\): \(k_{\text{RBF}}(\mathbf{x_1}, \mathbf{x_2}) = \theta_0 \exp \left ( -\frac{\|\mathbf{x_1} - \mathbf{x_2}\|^2} {2\theta_1^2} \right)\), where \(\theta_0\) is the amplitude parameter and \(\theta_1\) is the length scale parameter.

kernel_matrix(x1: Union[NDArray, Symbol], x2: Union[NDArray, Symbol]) Union[NDArray, Symbol][source]#
Parameters:
  • x1 (Tensor) – Feature data of shape (batch_size, history_length, num_features).

  • x2 (Tensor) – Feature data of shape (batch_size, history_length, num_features).

Returns:

RBF kernel matrix of shape (batch_size, history_length, history_length).

Return type:

Tensor

class gluonts.mx.kernels.RBFKernelOutput[source]#

Bases: KernelOutputDict

args_dim: Dict[str, int] = {'amplitude': 1, 'length_scale': 1}#
domain_map(F, amplitude, length_scale)[source]#

This function applies the softmax to the RBF Kernel hyper-parameters.

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

  • amplitude – RBF kernel amplitude hyper-parameter of shape (batch_size, 1, 1).

  • length_scale – RBF kernel length scale hyper-parameter of of shape (batch_size, 1, 1).

Returns:

Two GP RBF kernel hyper-parameters. Each is a Tensor of shape: (batch_size, 1, 1).

Return type:

Tuple[Tensor, Tenspr]

gp_params_scaling(F, past_target: Union[NDArray, Symbol], past_time_feat: Union[NDArray, Symbol]) Tuple[Union[NDArray, Symbol], Union[NDArray, Symbol], Union[NDArray, Symbol]][source]#

This function returns the scales for the GP RBF Kernel hyper- parameters by using the standard deviations of the past_target and past_time_features.

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

  • past_target – Training time series values of shape (batch_size, context_length).

  • past_time_feat – Training features of shape (batch_size, context_length, num_features).

Returns:

Two scaled GP hyper-parameters for the RBF Kernel and scaled model noise hyper-parameter. Each is a Tensor of shape (batch_size, 1, 1).

Return type:

Tuple

kernel_cls#

alias of RBFKernel