latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.logdet
- tensorplay.functional.logdet(input) Tensor[source]
Calculates log determinant of a square matrix or batches of square matrices.
It returns
-infif the input has a determinant of zero, andNaNif it has a negative determinant.Note
Backward through
logdet()internally uses SVD results wheninputis not invertible. In this case, double backward throughlogdet()will be unstable in wheninputdoesn’t have distinct singular values. Seetensorplay.linalg.svd()for details.See also
tensorplay.linalg.slogdet()computes the sign (resp. angle) and natural logarithm of the absolute value of the determinant of real-valued (resp. complex) square matrices.- Parameters:
input (Tensor) – the input tensor of size
(*, n, n)where*is zero or more batch dimensions.
Example:
>>> A = tensorplay.randn(3, 3) >>> tensorplay.det(A) tensor(0.2611) >>> tensorplay.logdet(A) tensor(-1.3430) >>> A tensor([[[ 0.9254, -0.6213], [-0.5787, 1.6843]], [[ 0.3242, -0.9665], [ 0.4539, -0.0887]], [[ 1.1336, -0.4025], [-0.7089, 0.9032]]]) >>> A.det() tensor([1.1990, 0.4099, 0.7386]) >>> A.det().log() tensor([ 0.1815, -0.8917, -0.3031])
Help improve this page
Found an error, an unclear step, or a missing example?

