Skip to content

Commit

Permalink
polish some docs (PaddlePaddle#2403)
Browse files Browse the repository at this point in the history
* polish some docs

* polish some docs

* Update square_cn.rst

* polish some docs

* polish some docs

* polish round docs

* polish round docs

* Update square_cn.rst
  • Loading branch information
WuHaobo authored Aug 19, 2020
1 parent 6e58088 commit 1d07d95
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 29 deletions.
36 changes: 36 additions & 0 deletions doc/fluid/api_cn/nn_cn/functional_cn/sigmoid_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. _cn_api_nn_functional_sigmoid:

sigmoid
-------------------------------

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

.. math::
out = \frac{1}{1 + e^{-x}}
参数:
- **x** (Tensor) - 输入的 `Tensor` ,数据类型为:float32、float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。

返回:
- Tensor,对输入x进行sigmoid激活后的Tensor,形状、数据类型与输入x一致。


**代码示例**:

.. code-block:: python
import numpy as np
import paddle
import paddle.nn.functional 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.sigmoid(x)
print(out.numpy())
# [0.40131234 0.450166 0.52497919 0.57444252]
Empty file modified doc/fluid/api_cn/tensor_cn/div_cn.rst
100755 → 100644
Empty file.
34 changes: 33 additions & 1 deletion doc/fluid/api_cn/tensor_cn/erf_cn.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
.. _cn_api_tensor_erf:

erf
-------------------------------
**版本升级,文档正在开发中**

.. py:function:: paddle.erf(x, name=None)
逐元素计算 Erf 激活函数。更多细节请参考 `Error function <https://en.wikipedia.org/wiki/Error_function>`_ 。


.. math::
out = \frac{2}{\sqrt{\pi}} \int_{0}^{x}e^{- \eta^{2}}d\eta
参数:
- **x** (Tensor) - 输入的 `Tensor` ,数据类型为: float16, float32, float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。

返回:
- Tensor,对输入x进行erf激活后的Tensor,形状、数据类型与输入 x 一致。


**代码示例**:

.. code-block:: python
import numpy as np
import paddle
paddle.disable_static()
x_data = np.array([-0.4, -0.2, 0.1, 0.3])
x = paddle.to_tensor(x_data)
out = paddle.erf(x)
print(out.numpy())
# [-0.42839236 -0.22270259 0.11246292 0.32862676]
26 changes: 25 additions & 1 deletion doc/fluid/api_cn/tensor_cn/round_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

round
-------------------------------
:doc_source: paddle.fluid.layers.round

.. py:function:: paddle.round(x, name=None)
该OP将输入中的数值四舍五入到最接近的整数数值。

参数:
- **x** (Tensor) - 输入的 `Tensor` ,数据类型为: float16, float32, float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。

返回:
- Tensor,对输入x四舍五入后的Tensor,形状、数据类型与输入x一致。


**代码示例**:

.. code-block:: python
import numpy as np
import paddle
paddle.disable_static()
x_data = np.array([-0.5, -0.2, 0.6, 1.5])
x = paddle.to_tensor(x_data)
out = paddle.round(x)
print(out.numpy())
# [-1. -0. 1. 2.]
35 changes: 34 additions & 1 deletion doc/fluid/api_cn/tensor_cn/rsqrt_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

rsqrt
-------------------------------
:doc_source: paddle.fluid.layers.rsqrt

.. py:function:: paddle.rsqrt(x, name=None)
该OP为rsqrt激活函数。

注:输入x应确保为非 **0** 值,否则程序会抛异常退出。

其运算公式如下:

.. math::
out = \frac{1}{\sqrt{x}}
参数:
- **x** (Tensor) - 输入的 `Tensor` ,数据类型为:float32、float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。

返回:
- Tensor,对输入x进行rsqrt激活后的Tensor,形状、数据类型与输入x一致。

**代码示例**:

.. code-block:: python
import numpy as np
import paddle
paddle.disable_static()
x_data = np.array([0.1, 0.2, 0.3, 0.4])
x = paddle.to_tensor(x_data)
out = paddle.rsqrt(x)
print(out.numpy())
# [3.16227766 2.23606798 1.82574186 1.58113883]
40 changes: 15 additions & 25 deletions doc/fluid/api_cn/tensor_cn/sin_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
sin
-------------------------------

.. py:function:: paddle.sin(x, name=None, out=None)
:alias_main: paddle.sin
:alias: paddle.sin,paddle.tensor.sin,paddle.tensor.math.sin
:update_api: paddle.fluid.layers.sin
.. py:function:: paddle.sin(x, name=None)
Expand All @@ -16,29 +12,23 @@ sin
.. math::
out = sin(x)
参数:
- **x** (Variable) - 支持任意维度的Tensor。数据类型为float32,float64或float16。
- **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
- **out** (Variable, 可选) – 指定存储运算结果的Tensor。如果设置为None或者不设置,将创建新的Tensor存储运算结果,默认值为None。
参数:
- **x** (Tensor) - 输入的 `Tensor` ,数据类型为: float16, float32, float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。

返回:
- Tensor,对输入x计算sin值后的Tensor,形状、数据类型同输入x一致。

返回:返回类型为Variable(Tensor|LoDTensor), 数据类型同输入一致。

**代码示例**:

.. code-block:: python
import numpy as np
import paddle
import paddle.fluid as fluid
inputs = fluid.layers.data(name="x", shape = [3], dtype='float32')
output = paddle.sin(inputs)
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program())
img = np.array([0, 45, 90]).astype(np.float32)
res = exe.run(fluid.default_main_program(), feed={'x':img}, fetch_list=[output])
print(res)
# [array([0. , 0.8509035 , 0.89399666], dtype=float32)]
import numpy as np
import paddle
paddle.disable_static()
x_data = np.array([-0.4, -0.2, 0.1, 0.3])
x = paddle.to_tensor(x_data)
out = paddle.sin(x)
print(out.numpy())
# [-0.38941834 -0.19866933 0.09983342 0.29552021]
30 changes: 29 additions & 1 deletion doc/fluid/api_cn/tensor_cn/square_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

square
-------------------------------
:doc_source: paddle.fluid.layers.square

.. py:function:: paddle.square(x,name=None)
该OP执行逐元素取平方运算。

.. math::
out = x^2
参数:
- **x** (Tensor) - 输入的 `Tensor` ,数据类型为:float32、float64。
- **name** (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name` 。

返回:
- Tensor,对输入x取平方后的Tensor,形状、数据类型与输入x一致。


**代码示例**:

.. code-block:: python
import numpy as np
import paddle
paddle.disable_static()
x_data = np.array([-0.4, -0.2, 0.1, 0.3])
x = paddle.to_tensor(x_data)
out = paddle.square(x)
print(out.numpy())
# [0.16 0.04 0.01 0.09]

0 comments on commit 1d07d95

Please sign in to comment.