mindspore.ops.coo_log

View Source On Gitee
mindspore.ops.coo_log(x: COOTensor)[source]

Returns the natural logarithm of a COOTensor element-wise.

\[y_i = \log_e(x_i)\]

Warning

If the input value of operator Log is within the range (0, 0.01] or [0.95, 1.05], the output accuracy may be affacted.

Parameters

x (COOTensor) – The value must be greater than 0.

Returns

COOTensor, has the same shape and dtype as the x.

Raises
  • TypeError – If x is not a COOTensor.

  • TypeError – If dtype of x is not float16, float32 or float64 on GPU and CPU.

  • TypeError – If dtype of x is not float16 or float32 on Ascend.

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_log(x)
>>> print(output.values)
[       nan 0.69314575]