From ebc06c71619d00d72bdefb85aede6e3bfba0df8c Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Fri, 14 Aug 2020 19:35:13 +0800 Subject: [PATCH] Update docs for `abs` `acos` `asin` `atan` `ceil` `cos` (#2326) * Update docs for `abs` `acos` `asin` `atan` `ceil` `cos` update code samples `Variable` -> `Tensor` remove activation wording explain cos input/output range misc fixes * Apply input template * Update `enable_imperative` -> `disable_static` --- doc/fluid/api_cn/layers_cn/abs_cn.rst | 22 +++++++++++------- doc/fluid/api_cn/layers_cn/acos_cn.rst | 25 +++++++++++---------- doc/fluid/api_cn/layers_cn/asin_cn.rst | 26 ++++++++++----------- doc/fluid/api_cn/layers_cn/atan_cn.rst | 29 ++++++++++++------------ doc/fluid/api_cn/layers_cn/ceil_cn.rst | 26 ++++++++++----------- doc/fluid/api_cn/layers_cn/cos_cn.rst | 31 +++++++++++++------------- 6 files changed, 82 insertions(+), 77 deletions(-) diff --git a/doc/fluid/api_cn/layers_cn/abs_cn.rst b/doc/fluid/api_cn/layers_cn/abs_cn.rst index cf726de9f..3c0cdf4f0 100644 --- a/doc/fluid/api_cn/layers_cn/abs_cn.rst +++ b/doc/fluid/api_cn/layers_cn/abs_cn.rst @@ -11,23 +11,29 @@ abs -绝对值激活函数。 +绝对值函数。 .. math:: out = |x| 参数: - - **x** (Variable)- 多维Tensor,数据类型为float32或float64。 - - **name** (str) – 该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` ,默认值为None。 + - x (Tensor) - 输入的Tensor,数据类型为:float32、float64。 + - name (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 -返回:表示绝对值结果的Tensor,数据类型与x相同。 +返回:输出Tensor,与 ``x`` 维度相同、数据类型相同。 -返回类型:Variable +返回类型:Tensor **代码示例**: .. code-block:: python - import paddle.fluid as fluid - data = fluid.layers.data(name="input", shape=[32, 784]) - result = fluid.layers.abs(data) + import paddle + import numpy as np + + paddle.disable_static() + x_data = np.array([-1, -2, -3, -4]).astype(np.float32) + x = paddle.to_variable(x_data) + res = paddle.abs(x) + print(res.numpy()) + # [1, 2, 3, 4] diff --git a/doc/fluid/api_cn/layers_cn/acos_cn.rst b/doc/fluid/api_cn/layers_cn/acos_cn.rst index 9185569aa..dad19ff25 100644 --- a/doc/fluid/api_cn/layers_cn/acos_cn.rst +++ b/doc/fluid/api_cn/layers_cn/acos_cn.rst @@ -11,29 +11,30 @@ acos -arccosine激活函数。 +arccosine函数。 .. math:: out = cos^{-1}(x) 参数: - - **x(Variable)** - acos的输入Tensor,数据类型为 float32 或 float64 - - **name** (str|None) – 具体用法请参见 :ref:`cn_api_guide_Name` ,一般无需设置,默认值为None。 -返回: `acos` 的输出Tensor,数据类型与 `x` 相同。 + - x (Tensor) - 输入的Tensor,数据类型为:float32、float64。 + - name (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 -返回类型: Variable +返回:输出Tensor,与 ``x`` 维度相同、数据类型相同。 +返回类型: Tensor **代码示例**: .. code-block:: python - import paddle.fluid as fluid - data = fluid.layers.data(name="input", shape=[4]) - # if data is [-0.8183, 0.4912, -0.6444, 0.0371] - result = fluid.layers.acos(data) - # result is [2.5293, 1.0573, 2.2711, 1.5336] - - + import paddle + import numpy as np + paddle.disable_static() + x_data = np.array([-0.8183, 0.4912, -0.6444, 0.0371]).astype(np.float32) + x = paddle.to_variable(x_data) + res = paddle.acos(x) + print(res.numpy()) + # [2.5293, 1.0573, 2.2711, 1.5336] diff --git a/doc/fluid/api_cn/layers_cn/asin_cn.rst b/doc/fluid/api_cn/layers_cn/asin_cn.rst index 03109d28e..3635c8a3f 100644 --- a/doc/fluid/api_cn/layers_cn/asin_cn.rst +++ b/doc/fluid/api_cn/layers_cn/asin_cn.rst @@ -11,29 +11,29 @@ asin -arcsine激活函数。 +arcsine函数。 .. math:: out = sin^{-1}(x) - 参数: - - **x(Variable)** - asin的输入Tensor,数据类型为 float32 或 float64 - - **name** (str|None) – 具体用法请参见 :ref:`cn_api_guide_Name` ,一般无需设置,默认值为None。 + - x (Tensor) - 输入的Tensor,数据类型为:float32、float64。 + - name (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 -返回: `asin` 的输出Tensor,数据类型与 `x` 相同。 +返回:输出Tensor,与 ``x`` 维度相同、数据类型相同。 -返回类型: Variable +返回类型: Tensor **代码示例**: .. code-block:: python - import paddle.fluid as fluid - data = fluid.layers.data(name="input", shape=[4]) - # if data is [-0.8183, 0.4912, -0.6444, 0.0371] - result = fluid.layers.asin(data) - # result is [-0.9585, 0.5135, -0.7003, 0.0372] - - + import paddle + import numpy as np + paddle.disable_static() + x_data = np.array([-0.8183, 0.4912, -0.6444, 0.0371]).astype(np.float32) + x = paddle.to_variable(x_data) + res = paddle.asin(x) + print(res.numpy()) + # [-0.9585, 0.5135, -0.7003, 0.0372] diff --git a/doc/fluid/api_cn/layers_cn/atan_cn.rst b/doc/fluid/api_cn/layers_cn/atan_cn.rst index 1c36f1047..5cd60cd44 100644 --- a/doc/fluid/api_cn/layers_cn/atan_cn.rst +++ b/doc/fluid/api_cn/layers_cn/atan_cn.rst @@ -11,30 +11,29 @@ atan -arctanh激活函数。 +arctangent函数。 .. math:: - out = tanh^{-1}(x) + out = tan^{-1}(x) 参数: - - **x(Variable)** - atan的输入Tensor,数据类型为 float32 或 float64 - - **name** (str|None) – 具体用法请参见 :ref:`cn_api_guide_Name` ,一般无需设置,默认值为None。 + - x (Tensor) - 输入的Tensor,数据类型为:float32、float64。 + - name (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 -返回: `atan` 的输出Tensor,数据类型与 `x` 相同。 +返回:输出Tensor,与 ``x`` 维度相同、数据类型相同。 -返回类型: Variable +返回类型: Tensor **代码示例**: .. code-block:: python - import paddle.fluid as fluid - data = fluid.layers.data(name="input", shape=[4]) - # if data is [-0.8183, 0.4912, -0.6444, 0.0371] - result = fluid.layers.atan(data) - # result is [-0.6858, 0.4566, -0.5724, 0.0371] - - - - + import paddle + import numpy as np + paddle.disable_static() + x_data = np.array([-0.8183, 0.4912, -0.6444, 0.0371]).astype(np.float32) + x = paddle.to_variable(x_data) + res = paddle.atan(x) + print(res.numpy()) + # [-0.6858, 0.4566, -0.5724, 0.0371] diff --git a/doc/fluid/api_cn/layers_cn/ceil_cn.rst b/doc/fluid/api_cn/layers_cn/ceil_cn.rst index 27ca3dd54..81a8265af 100644 --- a/doc/fluid/api_cn/layers_cn/ceil_cn.rst +++ b/doc/fluid/api_cn/layers_cn/ceil_cn.rst @@ -19,24 +19,24 @@ ceil 参数: - - **x** (Variable) - 该OP的输入为多维Tensor。数据类型为float32或float64。 - - **name** (str, 可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为None。 + - x (Tensor) - 输入的Tensor,数据类型为:float32、float64。 + - name (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 -返回: 输出为Tensor,与 ``x`` 维度相同、数据类型相同。 +返回:输出Tensor,与 ``x`` 维度相同、数据类型相同。 -返回类型: Variable +返回类型: Tensor **代码示例**: .. code-block:: python - import paddle.fluid as fluid - import numpy as np + import paddle + import numpy as np - input_ceil = np.array([[-1.5,6],[1,15.6]]) - with fluid.dygraph.guard(): - x = fluid.dygraph.to_variable(input_ceil) - y = fluid.layers.ceil(x) - print(y.numpy()) - # [[-1. 6.] - # [ 1. 16.]] + paddle.disable_static() + x_data = np.array([[-1.5,6],[1,15.6]]).astype(np.float32) + x = paddle.to_variable(x_data) + res = paddle.ceil(x) + print(res.numpy()) + # [[-1. 6.] + # [ 1. 16.]] diff --git a/doc/fluid/api_cn/layers_cn/cos_cn.rst b/doc/fluid/api_cn/layers_cn/cos_cn.rst index 4f31c473c..99e6b061f 100644 --- a/doc/fluid/api_cn/layers_cn/cos_cn.rst +++ b/doc/fluid/api_cn/layers_cn/cos_cn.rst @@ -13,32 +13,31 @@ cos 余弦函数。 +输入范围是 `(-inf, inf)` , 输出范围是 `[-1,1]`。若输入超出边界则结果为`nan`。 + .. math:: out = cos(x) - - 参数: - - **x** (Variable) - 该OP的输入为多维Tensor,数据类型为float32,float64。 - - **name** (str, 可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为None。 - + - x (Tensor) - 输入的Tensor,数据类型为:float32、float64。 + - name (str,可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 -返回:输出为Tensor,与 ``x`` 维度相同、数据类型相同。 +返回:输出Tensor,与 ``x`` 维度相同、数据类型相同。 -返回类型:Variable +返回类型:Tensor **代码示例**: .. code-block:: python - import paddle.fluid as fluid - import numpy as np + import paddle + import numpy as np - input_cos = np.array([[-1,np.pi],[1,15.6]]) - with fluid.dygraph.guard(): - x = fluid.dygraph.to_variable(input_cos) - y = fluid.layers.cos(x) - print(y.numpy()) - # [[ 0.54030231 -1. ] - # [ 0.54030231 -0.99417763]] + paddle.disable_static() + x_data = np.array([[-1,np.pi],[1,15.6]]).astype(np.float32) + x = paddle.to_variable(x_data) + res = paddle.cos(x) + print(res.numpy()) + # [[ 0.54030231 -1. ] + # [ 0.54030231 -0.99417763]] -- GitLab