positive_diag#

bayesflow.utils.positive_diag(x: Tensor, method='default') Tensor[source]#

Ensures that matrix elements on diagonal are positive.

Parameters:
xTensor of shape (batch_size, n, n)

Batch of matrices.

methodstr, optional

Method by which to ensure positivity of diagonal entries. Choose from - “shifted_softplus”: softplus(x + 0.5413) - “exp”: exp(x) Both methods map a matrix filled with zeros to the unit matrix. Default is “shifted_softplus”.

Returns:
Tensor of shape (batch_size, n, n)