PyTorch torch.logdet function
PyTorch torch reference manual
torch.logdet is a function in PyTorch used to compute the logarithm of the determinant of a matrix.
Function definition
torch.logdet(input)
Usage examples
Example
import
torch
Create a square matrix
A
=
torch.
tensor
(
[
[
2.0
,
1.0
]
,
[
1.0
,
3.0
]
]
)
Compute the logarithm of the determinant
log_det
=
torch.
logdet
(
A
)
(
"Log determinant:"
,
log_det
)
The output is:
行列式对数: tensor(1.6094)