Skip to content

Commit

Permalink
Update log log1p docs (PaddlePaddle#2337)
Browse files Browse the repository at this point in the history
* remove the out args

* update log docs

* update log1p docs
  • Loading branch information
WuHaobo authored Aug 14, 2020
1 parent 3c98fdd commit ea40812
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 21 deletions.
35 changes: 15 additions & 20 deletions doc/fluid/api_cn/tensor_cn/log1p_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
log1p
-------------------------------

.. py:function:: paddle.tensor.log1p(x, out=None, name=None)
.. py:function:: paddle.log1p(x, name=None)
:alias_main: paddle.log1p
:alias: paddle.log1p,paddle.tensor.log1p,paddle.tensor.math.log1p
Expand All @@ -18,32 +18,27 @@ log1p
参数:
- **x** (Variable) – 该OP的输入为LodTensor/Tensor。数据类型为float32,float64。
- **out** (Variable, 可选) - 指定算子输出结果的LoDTensor/Tensor,可以是程序中已经创建的任何Variable。默认值为None,此时将创建新的Variable来保存输出结果。
- **x** (Tensor) – 指定输入为一个多维的Tensor。数据类型为float32,float64。
- **name** (str,可选) – 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,默认值为None。

返回:Log1p算子自然对数输出

返回类型: Variable - 该OP的输出为LodTensor/Tensor,数据类型为输入一致。
返回类型: Tensor - 该OP的输出为一个多维的Tensor,数据类型为输入一致。


**代码示例**

.. code-block:: python
import paddle
import paddle.fluid as fluid
import numpy as np
x = fluid.data(name="x", shape=[2,1], dtype="float32")
res = paddle.log1p(x) # paddle.log1p等价于 paddle.tensor.log1p
# 举例选择CPU计算环境
exe = fluid.Executor(fluid.CPUPlace())
# 执行静态图,输出结果
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]]
import paddle
import numpy as np
paddle.enable_imperative()
x = np.array([[1, 2], [3, 4]]).astype('float32')
x1 = paddle.imperative.to_variable(x)
out1 = paddle.log1p(x1)
print(out1.numpy())
# [[0.6931472 1.0986123]
# [1.3862944 1.609438 ]]
39 changes: 38 additions & 1 deletion doc/fluid/api_cn/tensor_cn/log_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@

log
-------------------------------
:doc_source: paddle.fluid.layers.log

.. py:function:: paddle.log(x, name=None)
:alias_main: paddle.log
:alias: paddle.log,paddle.tensor.log,paddle.tensor.math.log
:old_api: paddle.fluid.layers.log




Log激活函数(计算自然对数)

.. math::
\\Out=ln(x)\\
参数:
- **x** (Tensor) – 指定输入为一个多维的Tensor。数据类型为float32,float64。
- **name** (str,可选) – 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,默认值为None。

返回:Log算子自然对数输出

返回类型: Tensor - 该OP的输出为一个多维的Tensor,数据类型为输入一致。


**代码示例**

.. code-block:: python
import paddle
import numpy as np
paddle.enable_imperative()
x = np.array([[1, 2], [3, 4]]).astype('float32')
x1 = paddle.imperative.to_variable(x)
out1 = paddle.log(x1)
print(out1.numpy())
# [[0. 0.6931472]
# [1.0986123 1.3862944]]

0 comments on commit ea40812

Please sign in to comment.