Detailed explanation of common linear functions in Python


Pyrorch’s linear function mainly encapsulates Blas and LAPACK, and its usage and interface are similar.

The following linear functions are commonly used:

function function
trace Sum of diagonal elements (trace of matrix)
diag Diagonal element
triu/tril Upper / lower triangle of the matrix, offset can be specified
mm/bmm Matrix multiplication, matrix multiplication of batch
t Transposition
dot/cross Inner product / outer product
inverse Inverse matrix
svd singular value decomposition

Note: transpose the matrix will make the storage space discontinuous, so call its. Contiguous method to make it continuous.

For example:

import torch as t
Output: false
Output: true

The above detailed explanation of commonly used linear functions in Python is the whole content shared by Xiaobian. I hope I can give you a reference, and I hope you can support developeppaer more.