mindspore.ops.coo_inv

mindspore.ops.coo_inv(x: COOTensor)[source]

Computes Reciprocal of input COOTensor element-wise.

\[out_i = \frac{1}{x_{i} }\]
Parameters

x (COOTensor) – Input COOTensor. Must be one of the following types: float16, float32 or int32.

Returns

COOTensor, has the same type and shape as input shape value.

Raises
  • TypeError – If x is not a COOTensor.

  • TypeError – If dtype of x is not one of float16, float32, int32.

Supported Platforms:

Ascend GPU CPU

Examples

>>> from mindspore import dtype as mstype
>>> from mindspore import Tensor, ops, COOTensor
>>> indices = Tensor([[0, 1], [1, 2]], dtype=mstype.int64)
>>> values = Tensor([-1, 2], dtype=mstype.float32)
>>> shape = (3, 4)
>>> x = COOTensor(indices, values, shape)
>>> output = ops.coo_inv(x)
>>> print(output.values)
[-1.   0.5]