# log¶

paddle.fluid.layers.log(x, name=None)[source]

Calculates the natural log of the given input tensor, element-wise.

$Out = \ln(x)$
Parameters
• x (Variable) – Input LoDTensor or Tensor. Must be one of the following types: float32, float64.

• name (str|None) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name

Returns

The natural log of the input LoDTensor or Tensor computed element-wise.

Return type

Variable

Examples

import paddle.fluid as fluid
import numpy as np

# Graph Organizing
x = fluid.layers.data(name="x", shape=[1], dtype="float32")
res = fluid.layers.log(x)

# Create an executor using CPU as an example
exe = fluid.Executor(fluid.CPUPlace())

# Execute
x_i = np.array([[1], [2]]).astype(np.float32)
res_val, = exe.run(fluid.default_main_program(), feed={'x':x_i}, fetch_list=[res])
print(res_val) # [[0.], [0.6931472]]