gluonts.support.linalg_util module¶

gluonts.support.linalg_util.batch_diagonal(F, matrix: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], num_data_points: Optional[int] = None, ctx=cpu(0), float_type=<class 'numpy.float32'>) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

This function extracts the diagonal of a batch matrix.

Parameters: F – A module that can either refer to the Symbol API or the NDArray API in MXNet. matrix – matrix of shape (batch_size, num_data_points, num_data_points). num_data_points – Number of rows in the kernel_matrix. Diagonals of kernel_matrix of shape (batch_size, num_data_points, 1). Tensor
gluonts.support.linalg_util.jitter_cholesky(F, matrix: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], num_data_points: Optional[int] = None, ctx: mxnet.context.Context = cpu(0), float_type: gluonts.core.component.DType = <class 'numpy.float64'>, max_iter_jitter: int = 10, neg_tol: float = -1e-08, diag_weight: float = 1e-06, increase_jitter: int = 10) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None][source]

This function applies the jitter method. It iteratively tries to compute the Cholesky decomposition and adds a positive tolerance to the diagonal that increases at each iteration until the matrix is positive definite or the maximum number of iterations has been reached.

Parameters: matrix – Kernel matrix of shape (batch_size, num_data_points, num_data_points). num_data_points – Number of rows in the kernel_matrix. ctx – Determines whether to compute on the cpu or gpu. float_type – Determines whether to use single or double precision. max_iter_jitter – Maximum number of iterations for jitter to iteratively make the matrix positive definite. neg_tol – Parameter in the jitter methods to eliminate eliminate matrices with diagonal elements smaller than this when checking if a matrix is positive definite. diag_weight – Multiple of mean of diagonal entries to initialize the jitter. increase_jitter – Each iteration multiply by jitter by this amount The method either fails to make the matrix positive definite within the maximum number of iterations and outputs an error or succeeds and returns the lower triangular Cholesky factor L of shape (batch_size, num_data_points, num_data_points) Optional[Tensor]
gluonts.support.linalg_util.jitter_cholesky_eig(F, matrix: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], num_data_points: Optional[int] = None, ctx: mxnet.context.Context = cpu(0), float_type: gluonts.core.component.DType = <class 'numpy.float64'>, diag_weight: float = 1e-06) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

This function applies the jitter method using the eigenvalue decomposition. The eigenvalues are bound below by the jitter, which is proportional to the mean of the diagonal elements

Parameters: F – A module that can either refer to the Symbol API or the NDArray API in MXNet. matrix – Matrix of shape (batch_size, num_data_points, num_data_points). num_data_points – Number of rows in the kernel_matrix. ctx – Determines whether to compute on the cpu or gpu. float_type – Determines whether to use single or double precision. Returns the approximate lower triangular Cholesky factor L of shape (batch_size, num_data_points, num_data_points) Tensor
gluonts.support.linalg_util.lower_triangular_ones(F, d: int, offset: int = 0) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Constructs a lower triangular matrix consisting of ones.

Parameters: F – d – Dimension of the output tensor, whose shape will be (d, d). offset – Indicates how many diagonals to set to zero in the lower triangular part. By default, offset = 0, so the output matrix contains also the main diagonal. For example, if offset = 1 then the output will be a strictly lower triangular matrix (i.e. the main diagonal will be zero). Tensor of shape (d, d) consisting of ones in the strictly lower triangular part, and zeros elsewhere. Tensor