mindspore.ops.log

mindspore.ops.log(input)[source]

Returns the natural logarithm of a tensor 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

input (Tensor) – Input Tensor of any dimension. The value must be greater than 0.

Returns

Tensor, has the same shape and dtype as the input.

Raises
  • TypeError – If input is not a Tensor.

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

  • TypeError – If dtype of input 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 = ops.log(x)
>>> print(output)
[0.        0.6931472 1.3862944]