Skip to content

Commit

Permalink
refine sign tanh api, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxicoding committed Aug 20, 2020
1 parent d5e19b9 commit 5ff4e6b
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 78 deletions.
6 changes: 0 additions & 6 deletions doc/fluid/api_cn/layers_cn/sign_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ sign

.. py:function:: paddle.fluid.layers.sign(x)
:alias_main: paddle.sign
:alias: paddle.sign,paddle.tensor.sign,paddle.tensor.math.sign
:old_api: paddle.fluid.layers.sign



此OP对输入x中每个元素进行正负判断,并且输出正负判断值:1代表正,-1代表负,0代表零。

参数:
Expand Down
36 changes: 13 additions & 23 deletions doc/fluid/api_cn/layers_cn/tanh_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,31 @@ tanh
.. py:function:: paddle.fluid.layers.tanh(x, name=None)
tanh 激活函数

.. math::
out = \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
参数:

- **x** - Tanh算子的输入
- **name** (str|None) - 该层名称(可选)。若设为None,则自动为该层命名
- **x** (Tensor) - Tanh算子的输入, 多维Tensor,数据类型为 float16,float32或float64。
- **name** (str, 可选) - 该层名称(可选,默认为None)。具体用法请参见 :ref:`api_guide_Name`

返回: 张量(Tensor)
返回: tanh的输出Tensor,和输入有着相同类型和shape。

返回类型: 变量(Variable)
返回类型: Tensor

**代码示例**:

.. code-block:: python
import paddle.fluid as fluid
data = fluid.layers.data(name="input", shape=[32, 784])
result = fluid.layers.tanh(data)
import numpy as np
import paddle
import paddle.nn.function as F
paddle.disable_static()
x_data = np.array([-0.4, -0.2, 0.1, 0.3])
x = paddle.to_tensor(x_data)
out = F.tanh(x)
print(out.numpy())
# [-0.37994896 -0.19737532 0.09966799 0.29131261]
1 change: 1 addition & 0 deletions doc/fluid/api_cn/nn_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ paddle.nn
nn_cn/ssd_loss_cn.rst
nn_cn/swish_cn.rst
nn_cn/switch_case_cn.rst
nn_cn/tanh_cn.rst
nn_cn/tanh_shrink_cn.rst
nn_cn/target_assign_cn.rst
nn_cn/teacher_student_sigmoid_loss_cn.rst
Expand Down
36 changes: 36 additions & 0 deletions doc/fluid/api_cn/nn_cn/tanh_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_nn_cn_tanh:

tanh
-------------------------------

.. py:function:: paddle.nn.function.tanh(x, name=None)
tanh 激活函数

.. math::
out = \frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
参数:

- **x** (Tensor) - Tanh算子的输入, 多维Tensor,数据类型为 float16,float32或float64。
- **name** (str, 可选) - 该层名称(可选,默认为None)。具体用法请参见 :ref:`api_guide_Name`。

返回: tanh的输出Tensor,和输入有着相同类型和shape。

返回类型: Tensor

**代码示例**:

.. code-block:: python
import numpy as np
import paddle
import paddle.nn.function as F
paddle.disable_static()
x_data = np.array([-0.4, -0.2, 0.1, 0.3])
x = paddle.to_tensor(x_data)
out = F.tanh(x)
print(out.numpy())
# [-0.37994896 -0.19737532 0.09966799 0.29131261]
1 change: 0 additions & 1 deletion doc/fluid/api_cn/tensor_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ paddle.tensor
tensor_cn/sum_cn.rst
tensor_cn/sums_cn.rst
tensor_cn/t_cn.rst
tensor_cn/tanh_cn.rst
tensor_cn/tensordot_cn.rst
tensor_cn/topk_cn.rst
tensor_cn/trace_cn.rst
Expand Down
27 changes: 25 additions & 2 deletions doc/fluid/api_cn/tensor_cn/sign_cn.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
.. _cn_api_tensor_cn_sign:
.. _cn_api_tensor_sign:

sign
-------------------------------
:doc_source: paddle.fluid.layers.sign

.. py:function:: paddle.tensor.math.sign(x, name=None)
此OP对输入x中每个元素进行正负判断,并且输出正负判断值:1代表正,-1代表负,0代表零。

参数:
- **x** (Tensor) – 进行正负值判断的多维Tensor,数据类型为 float16, float32或float64。
- **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。

返回:输出正负号Tensor,数据的shape大小及数据类型和输入 ``x`` 一致。

返回类型:Tensor

**代码示例**

.. code-block:: python
import numpy as np
import paddle
data = np.array([3.0, 0.0, -2.0, 1.7], dtype='float32')
paddle.disable_static()
x = paddle.to_tensor(data)
out = paddle.tensor.math.sign(x=x)
print(out) # [1.0, 0.0, -1.0, 1.0]
46 changes: 0 additions & 46 deletions doc/fluid/api_cn/tensor_cn/tanh_cn.rst

This file was deleted.

0 comments on commit 5ff4e6b

Please sign in to comment.