mindspore.ops.MatrixInverse

View Source On Gitee
class mindspore.ops.MatrixInverse(adjoint=False)[source]

Returns the inverse of the input matrix. If the matrix is irreversible, an error may be reported or an unknown result may be returned.

Note

The parameter ‘adjoint’ is only supporting False right now, because complex number is not supported at present.

Warning

This is an experimental API that is subject to change or deletion.

Parameters

adjoint (bool) – An optional bool. Default: False .

Inputs:
  • x (Tensor) - A matrix to be calculated. The matrix must be at least two dimensions, and the last two dimensions must be the same size.

Outputs:

Tensor, has the same type and shape as input x.

Raises
  • TypeError – If adjoint is not a bool.

  • TypeError – If x is not a Tensor.

  • ValueError – If the last two dimensions of x is not same size.

  • ValueError – If the dimension of x is less than 2.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> x = Tensor(np.array([[[-0.710504  , -1.1207525],
...                       [-1.7651395 , -1.7576632]],
...                      [[ 0.52412605,  1.9070215],
...                       [ 1.3384849 ,  1.4274558]]]), mindspore.float32)
>>> matrix_inverse = ops.MatrixInverse(adjoint=False)
>>> output = matrix_inverse(x)
>>> print(output)
[[[ 2.4095478  -1.5364188 ]
  [-2.419797    0.9740167 ]]
 [[-0.79111797  1.0569006 ]
  [ 0.74180895 -0.2904787 ]]]