mindspore.Tensor.log

Tensor.log()[source]

Returns the natural logarithm of self Tensor element-wise.

\[y_i = log_e(x_i)\]

Note

The dimension of the self Tensor on Ascend should be less than or equal to 8, and the dimension of the self Tensor on the CPU should be less than 8.

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 inaccurate.

Returns

Tensor, has the same shape and dtype as self.

Raises
  • TypeError – If dtype of self Tensor is not float16, float32, float64, complex64 or complex128 on GPU and CPU.

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

Supported Platforms:

Ascend GPU CPU

Examples

>>> x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float32)
>>> output = x.log()
>>> print(output)
[0.        0.6931472 1.3862944]