log1p

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

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

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.log1p, line 3)

Unexpected indentation.

Out = \ln(x+1)

System Message: WARNING/2 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.log1p, line 4)

Literal block ends without a blank line; unexpected unindent.

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

  • out (Variable, optional) – Optional output which can be any created Variable that meets the requirements to store the result of operation. if out is None, a new Varibale will be create to store the result.

  • name (str, optional) – 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

System Message: ERROR/3 (/usr/local/lib/python2.7/dist-packages/paddle/fluid/layers/nn.py:docstring of paddle.fluid.layers.log1p, line 19)

Error in “code-block” directive: maximum 1 argument(s) allowed, 49 supplied.

.. code-block:: python
    import paddle
    import paddle.fluid as fluid
    import numpy as np
    # Graph Organizing
    x = fluid.data(name="x", shape=[2,1], dtype="float32")
    res = fluid.layers.log1p(x)
    # Create an executor using CPU as an example
    exe = fluid.Executor(fluid.CPUPlace())
    # Execute
    x_i = np.array([[0], [1]]).astype(np.float32)
    res_val, = exe.run(fluid.default_main_program(), feed={'x':x_i}, fetch_list=[res])
    print(res_val) # [[0.], [0.6931472]]