mindspore.ops.MatrixInverse

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.

Parameters

adjoint (bool) – Whether to support complex matrix. False means that complex matrix is not supported. 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. dtypes: float32, float64.

Outputs:

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

Raises
  • TypeError – If adjoint is not a bool.

  • TypeError – If dtype of x is neither float32 nor float64.

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

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

Supported Platforms:

GPU CPU

Examples

>>> 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.4095483  -1.536419  ]
  [-2.4197974   0.97401696]]
 [[-0.79111797  1.0569006 ]
  [ 0.74180895 -0.2904787 ]]]