slogdet
- paddle.compat. slogdet ( x: Tensor, out: SlogdetResult | None = None ) SlogdetResult [source]
-
(PyTorch Compatible API) Calculates the sign and natural logarithm of the absolute value of a square matrix’s or batches square matrices’ determinant. The determinant can be computed with
sign * exp(logabsdet).Supports input of float, double, complex64, complex128.
Notes
For matrices that have zero determinant, this returns
(0, -inf).
2. For matrices with complex value, the \(abs(det)\) is the modulus of the determinant, and therefore \(sign = det / abs(det)\).
3. The return structure of this API has been revised from a single stacked Tensor of shape `[2, *]` (where index 0 was sign and index 1 was logabsdet) to a tuple of two independent Tensors `(sign, logabsdet)` (see PR #72505). This modification may cause incompatibility with models previously exported for inference that relied on the old return structure.
- Parameters
-
x (Tensor) – the batch of matrices of size \((*, n, n)\) where math:* is one or more batch dimensions.
out (SlogdetResult, optional) – The tuple of output tensor, contains
absandlogabsdet.
- Returns
-
A tuple containing two Tensors: (sign, logabsdet). The first Tensor represents the signs of the determinants and the second Tensor represents the natural logarithms of the absolute values of the determinants. Each output Tensor has a shape of \((*)\), where \(*\) matches the batch dimensions of the input x.
- Return type
-
SlogdetResult
Examples
>>> import paddle >>> x = paddle.to_tensor([[1., 0.], [0., 1.]]) >>> A = paddle.compat.slogdet(x) >>> print(A.sign) Tensor(shape=[], dtype=float32, place=Place(gpu:0), stop_gradient=True, 1.) >>> print(A.logabsdet) Tensor(shape=[], dtype=float32, place=Place(gpu:0), stop_gradient=True, 0.)
