Shortcuts

torch.linalg

Common linear algebra operations.

Matrix Properties

norm

Computes a vector or matrix norm.

vector_norm

Computes a vector norm.

matrix_norm

Computes a matrix norm.

det

Computes the determinant of a square matrix.

slogdet

Computes the sign and natural logarithm of the absolute value of the determinant of a square matrix.

cond

Computes the condition number of a matrix with respect to a matrix norm.

matrix_rank

Computes the numerical rank of a matrix.

Decompositions

cholesky

Computes the Cholesky decomposition of a complex Hermitian or real symmetric positive-definite matrix.

qr

Computes the QR decomposition of a matrix.

eig

Computes the eigenvalue decomposition of a square matrix if it exists.

eigvals

Computes the eigenvalues of a square matrix.

eigh

Computes the eigenvalue decomposition of a complex Hermitian or real symmetric matrix.

eigvalsh

Computes the eigenvalues of a complex Hermitian or real symmetric matrix.

svd

Computes the singular value decomposition (SVD) of a matrix.

svdvals

Computes the singular values of a matrix.

Solvers

solve

Computes the solution of a square system of linear equations with a unique solution.

lstsq

Computes a solution to the least squares problem of a system of linear equations.

Inverses

inv

Computes the inverse of a square matrix if it exists.

pinv

Computes the pseudoinverse (Moore-Penrose inverse) of a matrix.

Matrix Functions

matrix_exp

Computes the matrix exponential of a square matrix.

matrix_power

Computes the n-th power of a square matrix for an integer n.

Matrix Products

matmul

Alias for torch.matmul()

multi_dot

Efficiently multiplies two or more matrices by reordering the multiplications so that the fewest arithmetic operations are performed.

householder_product

Computes the first n columns of a product of Householder matrices.

Tensor Operations

tensorinv

Computes the multiplicative inverse of torch.tensordot().

tensorsolve

Computes the solution X to the system torch.tensordot(A, X) = B.

Experimental Functions

cholesky_ex

Computes the Cholesky decomposition of a complex Hermitian or real symmetric positive-definite matrix.

inv_ex

Computes the inverse of a square matrix if it is invertible.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources