paddle.linalg. inv ( x, name=None ) [source]

Takes the inverse of the square matrix. A square matrix is a matrix with the same number of rows and columns. The input can be a square matrix (2-D Tensor) or batches of square matrices.

  • x (Tensor) – The input tensor. The last two dimensions should be equal. When the number of dimensions is greater than 2, it is treated as batches of square matrix. The data type can be float32 and float64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.


A Tensor holds the inverse of x. The shape and data type

is the same as x.

Return type



import paddle

mat = paddle.to_tensor([[2, 0], [0, 2]], dtype='float32')
inv = paddle.inverse(mat)
print(inv) # [[0.5, 0], [0, 0.5]]