From 9cfbc9794fff89484d2e04642631df8bd11e89ea Mon Sep 17 00:00:00 2001 From: WangXi Date: Sat, 22 Aug 2020 16:03:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90doc=E3=80=91Add=20divide,=20floor=5Fdi?= =?UTF-8?q?vide,=20remainder=20doc=20(#2437)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/fluid/api/tensor/math.rst | 6 +- doc/fluid/api/tensor/math/divide.rst | 11 ++ doc/fluid/api/tensor/math/floor_divide.rst | 11 ++ doc/fluid/api/tensor/math/floor_mod.rst | 11 ++ doc/fluid/api/tensor/math/mod.rst | 11 ++ doc/fluid/api/tensor/math/remainder.rst | 11 ++ doc/fluid/api_cn/tensor_cn.rst | 6 +- doc/fluid/api_cn/tensor_cn/div_cn.rst | 160 ------------------ doc/fluid/api_cn/tensor_cn/divide_cn.rst | 43 +++++ .../api_cn/tensor_cn/floor_divide_cn.rst | 43 +++++ doc/fluid/api_cn/tensor_cn/floor_mod_cn.rst | 7 + doc/fluid/api_cn/tensor_cn/mod_cn.rst | 7 + doc/fluid/api_cn/tensor_cn/remainder_cn.rst | 42 +++++ 13 files changed, 207 insertions(+), 162 deletions(-) create mode 100644 doc/fluid/api/tensor/math/divide.rst create mode 100644 doc/fluid/api/tensor/math/floor_divide.rst create mode 100644 doc/fluid/api/tensor/math/floor_mod.rst create mode 100644 doc/fluid/api/tensor/math/mod.rst create mode 100644 doc/fluid/api/tensor/math/remainder.rst delete mode 100644 doc/fluid/api_cn/tensor_cn/div_cn.rst create mode 100644 doc/fluid/api_cn/tensor_cn/divide_cn.rst create mode 100644 doc/fluid/api_cn/tensor_cn/floor_divide_cn.rst create mode 100644 doc/fluid/api_cn/tensor_cn/floor_mod_cn.rst create mode 100644 doc/fluid/api_cn/tensor_cn/mod_cn.rst create mode 100644 doc/fluid/api_cn/tensor_cn/remainder_cn.rst diff --git a/doc/fluid/api/tensor/math.rst b/doc/fluid/api/tensor/math.rst index 0e0218b03..22f645a0f 100644 --- a/doc/fluid/api/tensor/math.rst +++ b/doc/fluid/api/tensor/math.rst @@ -10,7 +10,11 @@ math math/addmm.rst math/atan.rst math/clamp.rst - math/div.rst + math/divide.rst + math/floor_divide.rst + math/remainder.rst + math/floor_mod.rst + math/mod.rst math/elementwise_sum.rst math/log1p.rst math/logsumexp.rst diff --git a/doc/fluid/api/tensor/math/divide.rst b/doc/fluid/api/tensor/math/divide.rst new file mode 100644 index 000000000..db7c8aa3c --- /dev/null +++ b/doc/fluid/api/tensor/math/divide.rst @@ -0,0 +1,11 @@ +.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}` + !DO NOT EDIT THIS FILE MANUALLY! + +.. _api_tensor_math_divide: + +divide +------ + +.. autofunction:: paddle.tensor.math.divide + :noindex: + diff --git a/doc/fluid/api/tensor/math/floor_divide.rst b/doc/fluid/api/tensor/math/floor_divide.rst new file mode 100644 index 000000000..aed75d979 --- /dev/null +++ b/doc/fluid/api/tensor/math/floor_divide.rst @@ -0,0 +1,11 @@ +.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}` + !DO NOT EDIT THIS FILE MANUALLY! + +.. _api_tensor_math_floor_divide: + +floor_divide +------------ + +.. autofunction:: paddle.tensor.math.floor_divide + :noindex: + diff --git a/doc/fluid/api/tensor/math/floor_mod.rst b/doc/fluid/api/tensor/math/floor_mod.rst new file mode 100644 index 000000000..655e41911 --- /dev/null +++ b/doc/fluid/api/tensor/math/floor_mod.rst @@ -0,0 +1,11 @@ +.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}` + !DO NOT EDIT THIS FILE MANUALLY! + +.. _api_tensor_math_floor_mod: + +floor_mod +--------- + +.. autofunction:: paddle.tensor.math.floor_mod + :noindex: + diff --git a/doc/fluid/api/tensor/math/mod.rst b/doc/fluid/api/tensor/math/mod.rst new file mode 100644 index 000000000..a5e207a6c --- /dev/null +++ b/doc/fluid/api/tensor/math/mod.rst @@ -0,0 +1,11 @@ +.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}` + !DO NOT EDIT THIS FILE MANUALLY! + +.. _api_tensor_math_mod: + +mod +--- + +.. autofunction:: paddle.tensor.math.mod + :noindex: + diff --git a/doc/fluid/api/tensor/math/remainder.rst b/doc/fluid/api/tensor/math/remainder.rst new file mode 100644 index 000000000..6d753fd13 --- /dev/null +++ b/doc/fluid/api/tensor/math/remainder.rst @@ -0,0 +1,11 @@ +.. THIS FILE IS GENERATED BY `gen_doc.{py|sh}` + !DO NOT EDIT THIS FILE MANUALLY! + +.. _api_tensor_math_remainder: + +remainder +--------- + +.. autofunction:: paddle.tensor.math.remainder + :noindex: + diff --git a/doc/fluid/api_cn/tensor_cn.rst b/doc/fluid/api_cn/tensor_cn.rst index 79134b392..539bc95c9 100644 --- a/doc/fluid/api_cn/tensor_cn.rst +++ b/doc/fluid/api_cn/tensor_cn.rst @@ -33,7 +33,11 @@ paddle.tensor tensor_cn/cumsum_cn.rst tensor_cn/diag_cn.rst tensor_cn/dist_cn.rst - tensor_cn/div_cn.rst + tensor_cn/divide_cn.rst + tensor_cn/floor_divide_cn.rst + tensor_cn/remainder_cn.rst + tensor_cn/mod_cn.rst + tensor_cn/floor_mod_cn.rst tensor_cn/dot_cn.rst tensor_cn/einsum_cn.rst tensor_cn/elementwise_add_cn.rst diff --git a/doc/fluid/api_cn/tensor_cn/div_cn.rst b/doc/fluid/api_cn/tensor_cn/div_cn.rst deleted file mode 100644 index 14a6e0516..000000000 --- a/doc/fluid/api_cn/tensor_cn/div_cn.rst +++ /dev/null @@ -1,160 +0,0 @@ -.. _cn_api_tensor_div: - -div -------------------------------- - -.. py:function:: paddle.div(x, y, out=None, name=None) - -:alias_main: paddle.div -:alias: paddle.div,paddle.tensor.div,paddle.tensor.math.div -:update_api: paddle.fluid.layers.elementwise_div - - - -该OP是逐元素相除算子,输入 ``x`` 与输入 ``y`` 逐元素相除,并将各个位置的输出元素保存到返回结果中。 - -等式是: - -.. math:: - Out = X / Y - -- :math:`X` :多维Tensor。 -- :math:`Y` :维度必须小于等于X维度的Tensor。 - -对于这个运算算子有2种情况: - 1. :math:`Y` 的 ``shape`` 与 :math:`X` 相同。 - 2. :math:`Y` 的 ``shape`` 是 :math:`X` 的连续子序列。 - -对于情况2: - 1. 用 :math:`Y` 匹配 :math:`X` 的形状(shape),其中 ``axis`` 是 :math:`Y` 在 :math:`X` 上的起始维度的位置。 - 2. 如果 ``axis`` 为-1(默认值),则 :math:`axis= rank(X)-rank(Y)` 。 - 3. 考虑到子序列, :math:`Y` 的大小为1的尾部维度将被忽略,例如shape(Y)=(2,1)=>(2)。 - -例如: - -.. code-block:: text - - shape(X) = (2, 3, 4, 5), shape(Y) = (,) - shape(X) = (2, 3, 4, 5), shape(Y) = (5,) - shape(X) = (2, 3, 4, 5), shape(Y) = (4, 5), with axis=-1(default) or axis=2 - shape(X) = (2, 3, 4, 5), shape(Y) = (3, 4), with axis=1 - shape(X) = (2, 3, 4, 5), shape(Y) = (2), with axis=0 - shape(X) = (2, 3, 4, 5), shape(Y) = (2, 1), with axis=0 - -参数: - - **x** (Variable)- 多维 ``Tensor`` 或 ``LoDTensor`` 。数据类型为 ``float32`` 、 ``float64`` 、 ``int32`` 或 ``int64``。 - - **y** (Variable)- 多维 ``Tensor`` 或 ``LoDTensor`` 。数据类型为 ``float32`` 、 ``float64`` 、 ``int32`` 或 ``int64``。 - - **out** (Variable,可选)- 指定存储运算结果的 ``Tensor`` 。如果设置为None或者不设置,将创建新的 ``Tensor`` 存储运算结果,默认值为None。 - - **name** (str,可选)- 输出的名字。默认值为None。该参数供开发人员打印调试信息时使用,具体用法请参见 :ref:`api_guide_Name` 。 - - -返回: 多维 ``Tensor`` 或 ``LoDTensor`` , 维度和数据类型都与 ``x`` 相同。 - -返回类型: Variable - -**代码示例 1** - -.. code-block:: python - - - import paddle - import paddle.fluid as fluid - import numpy as np - - def gen_data(): - return { - "x": np.array([2, 3, 4]).astype('float32'), - "y": np.array([1, 5, 2]).astype('float32') - } - - x = fluid.data(name="x", shape=[3], dtype='float32') - y = fluid.data(name="y", shape=[3], dtype='float32') - z = paddle.div(x, y) - # z = x / y - - place = fluid.CPUPlace() - exe = fluid.Executor(place) - z_value = exe.run(feed=gen_data(), - fetch_list=[z.name]) - - print(z_value) # [2., 0.6, 2.] - - -**代码示例 2** - -.. code-block:: python - - import paddle - import paddle.fluid as fluid - import numpy as np - - def gen_data(): - return { - "x": np.ones((2, 3, 4, 5)).astype('float32'), - "y": np.zeros((4, 5)).astype('float32') - } - - x = fluid.data(name="x", shape=[2, 3, 4, 5], dtype='float32') - y = fluid.data(name="y", shape=[4, 5], dtype='float32') - z = paddle.div(x, y, name='z') - # z = x / y - - place = fluid.CPUPlace() - exe = fluid.Executor(place) - - z_value = exe.run(feed=gen_data(), - fetch_list=[z.name]) - - print(z_value[0]) - print(z_value[0].shape) # z.shape=[2,3,4,5] - - -**代码示例 3** - -.. code-block:: python - - import paddle - import paddle.fluid as fluid - import numpy as np - - def gen_data(): - return { - "x": np.random.randint(1, 5, size=[2, 3, 4, 5]).astype('float32'), - "y": np.random.randint(1, 5, size=[5]).astype('float32') - } - - x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32') - y = fluid.data(name="y", shape=[5], dtype='float32') - output = fluid.data(name="output", shape=[2,3,4,5], dtype="float32") - z = paddle.div(x, y, out=output) - # z = x / y - - place = fluid.CPUPlace() - exe = fluid.Executor(place) - - z_value = exe.run(feed=gen_data(), - fetch_list=[z.name]) - print(z_value[0]) - print(z_value[0].shape) # z.shape=[2,3,4,5] - - -**代码示例 4(动态图)** - -.. code-block:: python - - import paddle - import paddle.fluid as fluid - import numpy as np - - with fluid.dygraph.guard(fluid.CPUPlace()): - np_x = np.array([2, 3, 4]).astype('float64') - np_y = np.array([1, 5, 2]).astype('float64') - x = fluid.dygraph.to_variable(np_x) - y = fluid.dygraph.to_variable(np_y) - z = paddle.div(x, y) - np_z = z.numpy() - print(np_z) # [2., 0.6, 2.] - - - - diff --git a/doc/fluid/api_cn/tensor_cn/divide_cn.rst b/doc/fluid/api_cn/tensor_cn/divide_cn.rst new file mode 100644 index 000000000..d0b0113c2 --- /dev/null +++ b/doc/fluid/api_cn/tensor_cn/divide_cn.rst @@ -0,0 +1,43 @@ +.. _cn_api_tensor_divide: + +divide +------------------------------- + +.. py:function:: paddle.divide(x, y, name=None) + +该OP是逐元素相除算子,输入 ``x`` 与输入 ``y`` 逐元素相除,并将各个位置的输出元素保存到返回结果中。 +输入 ``x`` 与输入 ``y`` 必须可以广播为相同形状, 关于广播规则,请参考 :ref:`use_guide_broadcasting` + +等式为: + +.. math:: + Out = X / Y + +- :math:`X` :多维Tensor。 +- :math:`Y` :多维Tensor。 + +参数: + - x(Tensor)- 多维Tensor。数据类型为float32 、float64、int32或int64。 + - y(Tensor)- 多维Tensor。数据类型为float32 、float64、int32或int64。 + - name(str,可选)- 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 + + +返回: 多维 Tensor, 数据类型与 ``x`` 相同,维度为广播后的形状。 + +返回类型: Tensor + + +**代码示例** + +.. code-block:: python + + import paddle + import numpy as np + + paddle.disable_static() + np_x = np.array([2, 3, 4]).astype('float64') + np_y = np.array([1, 5, 2]).astype('float64') + x = paddle.to_tensor(np_x) + y = paddle.to_tensor(np_y) + z = paddle.divide(x, y) + print(z.numpy()) # [2., 0.6, 2.] diff --git a/doc/fluid/api_cn/tensor_cn/floor_divide_cn.rst b/doc/fluid/api_cn/tensor_cn/floor_divide_cn.rst new file mode 100644 index 000000000..c63ae4fd1 --- /dev/null +++ b/doc/fluid/api_cn/tensor_cn/floor_divide_cn.rst @@ -0,0 +1,43 @@ +.. _cn_api_tensor_floor_divide: + +floor_divide +------------------------------- + +.. py:function:: paddle.floor_divide(x, y, name=None) + +该OP是逐元素整除算子,输入 ``x`` 与输入 ``y`` 逐元素整除,并将各个位置的输出元素保存到返回结果中。 +输入 ``x`` 与输入 ``y`` 必须可以广播为相同形状, 关于广播规则,请参考 :ref:`use_guide_broadcasting` + +等式为: + +.. math:: + Out = X // Y + +- :math:`X` :多维Tensor。 +- :math:`Y` :多维Tensor。 + +参数: + - x(Tensor)- 多维Tensor。数据类型为int32或int64。 + - y(Tensor)- 多维Tensor。数据类型为int32或int64。 + - name(str,可选)- 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 + + +返回: 多维 Tensor, 数据类型与 ``x`` 相同,维度为广播后的形状。 + +返回类型: Tensor + + +**代码示例** + +.. code-block:: python + + import paddle + import numpy as np + + paddle.disable_static() + np_x = np.array([2, 3, 8, 7]) + np_y = np.array([1, 5, 3, 3]) + x = paddle.to_tensor(np_x) + y = paddle.to_tensor(np_y) + z = paddle.floor_divide(x, y) + print(z.numpy()) # [2, 0, 2, 2] \ No newline at end of file diff --git a/doc/fluid/api_cn/tensor_cn/floor_mod_cn.rst b/doc/fluid/api_cn/tensor_cn/floor_mod_cn.rst new file mode 100644 index 000000000..e9b9773c0 --- /dev/null +++ b/doc/fluid/api_cn/tensor_cn/floor_mod_cn.rst @@ -0,0 +1,7 @@ +.. _cn_api_tensor_cn_floor_mod: + +floor_mod +------------------------------- +:doc_source: paddle.tensor.remainder + + diff --git a/doc/fluid/api_cn/tensor_cn/mod_cn.rst b/doc/fluid/api_cn/tensor_cn/mod_cn.rst new file mode 100644 index 000000000..b7f34c81e --- /dev/null +++ b/doc/fluid/api_cn/tensor_cn/mod_cn.rst @@ -0,0 +1,7 @@ +.. _cn_api_tensor_cn_mod: + +mod +------------------------------- +:doc_source: paddle.tensor.remainder + + diff --git a/doc/fluid/api_cn/tensor_cn/remainder_cn.rst b/doc/fluid/api_cn/tensor_cn/remainder_cn.rst new file mode 100644 index 000000000..ccf124eb8 --- /dev/null +++ b/doc/fluid/api_cn/tensor_cn/remainder_cn.rst @@ -0,0 +1,42 @@ +.. _cn_api_tensor_remainder: + +remainder +------------------------------- + +.. py:function:: paddle.remainder(x, y, name=None) + +该OP是逐元素取模算子,输入 ``x`` 与输入 ``y`` 逐元素取模,并将各个位置的输出元素保存到返回结果中。 +输入 ``x`` 与输入 ``y`` 必须可以广播为相同形状, 关于广播规则,请参考 :ref:`use_guide_broadcasting` + +等式为: + +.. math:: + Out = X \% Y + +- :math:`X` :多维Tensor。 +- :math:`Y` :多维Tensor。 + +参数: + - x(Tensor)- 多维Tensor。数据类型为float32 、float64、int32或int64。 + - y(Tensor)- 多维Tensor。数据类型为float32 、float64、int32或int64。 + - name(str,可选)- 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 + + +返回: 多维 Tensor, 数据类型与 ``x`` 相同,维度为广播后的形状。 + +返回类型: Tensor + + +**代码示例** + +.. code-block:: python + + import paddle + import numpy as np + paddle.disable_static() + np_x = np.array([2, 3, 8, 7]) + np_y = np.array([1, 5, 3, 3]) + x = paddle.to_tensor(np_x) + y = paddle.to_tensor(np_y) + z = paddle.remainder(x, y) + print(z.numpy()) # [0, 3, 2, 1] \ No newline at end of file -- GitLab