From 03ae009dcef51c9d2ed8d7d3d981fc81b8f343df Mon Sep 17 00:00:00 2001 From: Hu Manyue Date: Sun, 30 Mar 2025 13:18:10 +0800 Subject: [PATCH 01/12] Add Inplace CN Doc No.12 --- docs/api/paddle/digamma__cn.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docs/api/paddle/digamma__cn.rst diff --git a/docs/api/paddle/digamma__cn.rst b/docs/api/paddle/digamma__cn.rst new file mode 100644 index 00000000000..79cd193aa27 --- /dev/null +++ b/docs/api/paddle/digamma__cn.rst @@ -0,0 +1,12 @@ +.. _cn_api_paddle_digamma_: + +digamma\_ +------------------------------- + +.. py:function:: paddle.digamma_(x, name=None) + +Inplace 版本的 :ref:`cn_api_paddle_digamma` API,对输入 x 采用 Inplace 策略。 + +更多关于 inplace 操作的介绍请参考 `3.1.3 原位(Inplace)操作和非原位操作的区别`_ 了解详情。 + +.. _3.1.3 原位(Inplace)操作和非原位操作的区别: https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/guides/beginner/tensor_cn.html#id3 \ No newline at end of file From 19e665c28d18d291cfcbe14ff93928fbd7697a55 Mon Sep 17 00:00:00 2001 From: Hu Manyue Date: Mon, 31 Mar 2025 11:25:06 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86Overview=5Fcn.?= =?UTF-8?q?rst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/paddle/Overview_cn.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api/paddle/Overview_cn.rst b/docs/api/paddle/Overview_cn.rst index 2a97eef75b7..bb1f8444b2c 100644 --- a/docs/api/paddle/Overview_cn.rst +++ b/docs/api/paddle/Overview_cn.rst @@ -63,6 +63,7 @@ tensor 数学操作 " :ref:`paddle.cummin ` ", "沿给定 axis 计算 Tensor x 的累计最小值" " :ref:`paddle.cumprod ` ", "沿给定 dim 计算 Tensor x 的累乘" " :ref:`paddle.digamma ` ", "逐元素计算输入 x 的 digamma 函数值" + " :ref:`paddle.digamma_ ` ", "Inplace 版本的 digamma API, 对输入 x 采用 Inplace 策略" " :ref:`paddle.divide ` ", "逐元素相除算子" " :ref:`paddle.equal ` ", "返回 x==y 逐元素比较 x 和 y 是否相等,相同位置的元素相同则返回 True,否则返回 False" " :ref:`paddle.equal_all ` ", "如果所有相同位置的元素相同返回 True,否则返回 False" From 5e560c90de6aabd91d0cd0075fa6e766b87f3b7f Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 20:55:01 +0800 Subject: [PATCH 03/12] Delete docs/api/paddle/static/nn/sequence_reshape_cn.rst --- .../paddle/static/nn/sequence_reshape_cn.rst | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 docs/api/paddle/static/nn/sequence_reshape_cn.rst diff --git a/docs/api/paddle/static/nn/sequence_reshape_cn.rst b/docs/api/paddle/static/nn/sequence_reshape_cn.rst deleted file mode 100644 index ac16f4fe03e..00000000000 --- a/docs/api/paddle/static/nn/sequence_reshape_cn.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. _cn_api_paddle_static_nn_sequence_reshape: - -sequence_reshape -------------------------------- - - -.. py:function:: paddle.static.nn.sequence_reshape(input, new_dim) - - -.. note:: - 该 API 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.reshape ` 。 - -在指定 ``new_dim`` 参数下,通过序列原始长度、和原始 shape 计算出新的 shape,以输出包含新维度(new_dim)下的 Tensor。目前仅支持 1-level Tensor,请确保(原长度*原维数)可以除以新的维数,且每个序列没有余数。 - -:: - - input 是一个 Tensor: - input.lod = [[0, 2, 6]] - input.data = [[1, 2], [3, 4], - [5, 6], [7, 8], - [9, 10], [11, 12]] - input.shape = [6, 2] - 设置 new_dim = 4 - 输出为 Tensor: - out.lod = [[0, 1, 3]] - - out.data = [[1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12]] - out.shape = [3, 4] - - - -参数 -::::::::: - - - **input** (Tensor) - 维度为 :math:`[M, K]` 的二维 Tensor,且仅支持 lod_level 为 1。数据类型为 int32,int64,float32 或 float64。 - - **new_dim** (int)- 指定 reshape 后的新维度,即对输入 Tensor 重新 reshape 后的新维度。 - -返回 -::::::::: -根据新维度重新 reshape 后的 Tensor,数据类型和输入一致。 - - -代码示例 -::::::::: - -COPY-FROM: paddle.static.nn.sequence_reshape From 2ba11d23cf00d0a188c69e4f5e631245a6743f24 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 20:55:25 +0800 Subject: [PATCH 04/12] Delete docs/api/paddle/static/nn/sequence_reverse_cn.rst --- .../paddle/static/nn/sequence_reverse_cn.rst | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 docs/api/paddle/static/nn/sequence_reverse_cn.rst diff --git a/docs/api/paddle/static/nn/sequence_reverse_cn.rst b/docs/api/paddle/static/nn/sequence_reverse_cn.rst deleted file mode 100644 index 4c2c7f31d03..00000000000 --- a/docs/api/paddle/static/nn/sequence_reverse_cn.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. _cn_api_paddle_static_nn_sequence_reverse: - -sequence_reverse -------------------------------- - -.. py:function:: paddle.static.nn.sequence_reverse(x, name=None) - - -.. note:: - 该 API 仅支持带有 LoD 信息的 Tensor。 - -输入的 Tensor,在每个序列(sequence)上进行反转。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。该 OP 在构建反向 :ref:`cn_api_paddle_nn_RNN` 网络时十分有用。 - -:: - - 输入 x 是一个 Tensor: - x.lod = [[0, 2, 5]] - x.data = [[1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - [13,14, 15, 16], - [17,18, 19, 20]] - x.shape = [5, 4] - - 输出 out 与 x 具有同样的 shape 和 LoD 信息: - out.lod = [[0, 2, 5]] - out.data = [[5, 6, 7, 8], - [1, 2, 3, 4], - [17,18, 19, 20], - [13,14, 15, 16], - [9, 10, 11, 12]] - out.shape = [5, 4] - - -参数 -::::::::: - - - **x** (Variable) - 输入是 LoD level 为 1 的 Tensor。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。数据类型为 float32,float64,int8,int32 或 int64。 - - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 - -返回 -::::::::: -输出在每个序列上反转后的 Tensor,数据类型和输入类型一致。 - -代码示例 -:::::::::::: - -COPY-FROM: paddle.static.nn.sequence_reverse From d0413cb18139446064eb837b600ef4455ed2e6c4 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 21:09:31 +0800 Subject: [PATCH 05/12] Update Overview_cn.rst --- docs/api/paddle/static/Overview_cn.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/api/paddle/static/Overview_cn.rst b/docs/api/paddle/static/Overview_cn.rst index 6c91a70b3dc..db51c5d26b9 100644 --- a/docs/api/paddle/static/Overview_cn.rst +++ b/docs/api/paddle/static/Overview_cn.rst @@ -79,8 +79,6 @@ Executor 相关 API " :ref:`sequence_last_step ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在最后一层 lod_level 上,选取其每个序列的最后一个时间步的特征向量作为池化后的输出向量" " :ref:`sequence_pad ` ", "仅支持带有 LoD 信息的 Tensor,将同一 batch 中的序列填充到一个一致的长度(由 maxlen 指定)" " :ref:`sequence_pool ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的池化操作" - " :ref:`sequence_reshape ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的变形操作" - " :ref:`sequence_reverse ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在每个序列上进行反转" " :ref:`sequence_slice ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,实现序列切片运算" " :ref:`sequence_softmax ` ", "仅支持带有 LoD 信息的 Tensor,根据 Tensor 信息将输入的第 0 维度进行划分,在划分的每一个区间内部进行运算" From 34ad82f3bd669f30bf6cea0437f743227f7bbad7 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 21:36:35 +0800 Subject: [PATCH 06/12] Update Overview_cn.rst --- docs/api/paddle/static/Overview_cn.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/api/paddle/static/Overview_cn.rst b/docs/api/paddle/static/Overview_cn.rst index db51c5d26b9..6c91a70b3dc 100644 --- a/docs/api/paddle/static/Overview_cn.rst +++ b/docs/api/paddle/static/Overview_cn.rst @@ -79,6 +79,8 @@ Executor 相关 API " :ref:`sequence_last_step ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在最后一层 lod_level 上,选取其每个序列的最后一个时间步的特征向量作为池化后的输出向量" " :ref:`sequence_pad ` ", "仅支持带有 LoD 信息的 Tensor,将同一 batch 中的序列填充到一个一致的长度(由 maxlen 指定)" " :ref:`sequence_pool ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的池化操作" + " :ref:`sequence_reshape ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的变形操作" + " :ref:`sequence_reverse ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在每个序列上进行反转" " :ref:`sequence_slice ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,实现序列切片运算" " :ref:`sequence_softmax ` ", "仅支持带有 LoD 信息的 Tensor,根据 Tensor 信息将输入的第 0 维度进行划分,在划分的每一个区间内部进行运算" From 70da887dace4f794444471ccff3abda633c43ce1 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 21:37:39 +0800 Subject: [PATCH 07/12] Create sequence_reshape_cn.rst --- .../paddle/static/nn/sequence_reshape_cn.rst | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/api/paddle/static/nn/sequence_reshape_cn.rst diff --git a/docs/api/paddle/static/nn/sequence_reshape_cn.rst b/docs/api/paddle/static/nn/sequence_reshape_cn.rst new file mode 100644 index 00000000000..ac16f4fe03e --- /dev/null +++ b/docs/api/paddle/static/nn/sequence_reshape_cn.rst @@ -0,0 +1,48 @@ +.. _cn_api_paddle_static_nn_sequence_reshape: + +sequence_reshape +------------------------------- + + +.. py:function:: paddle.static.nn.sequence_reshape(input, new_dim) + + +.. note:: + 该 API 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.reshape ` 。 + +在指定 ``new_dim`` 参数下,通过序列原始长度、和原始 shape 计算出新的 shape,以输出包含新维度(new_dim)下的 Tensor。目前仅支持 1-level Tensor,请确保(原长度*原维数)可以除以新的维数,且每个序列没有余数。 + +:: + + input 是一个 Tensor: + input.lod = [[0, 2, 6]] + input.data = [[1, 2], [3, 4], + [5, 6], [7, 8], + [9, 10], [11, 12]] + input.shape = [6, 2] + 设置 new_dim = 4 + 输出为 Tensor: + out.lod = [[0, 1, 3]] + + out.data = [[1, 2, 3, 4], + [5, 6, 7, 8], + [9, 10, 11, 12]] + out.shape = [3, 4] + + + +参数 +::::::::: + + - **input** (Tensor) - 维度为 :math:`[M, K]` 的二维 Tensor,且仅支持 lod_level 为 1。数据类型为 int32,int64,float32 或 float64。 + - **new_dim** (int)- 指定 reshape 后的新维度,即对输入 Tensor 重新 reshape 后的新维度。 + +返回 +::::::::: +根据新维度重新 reshape 后的 Tensor,数据类型和输入一致。 + + +代码示例 +::::::::: + +COPY-FROM: paddle.static.nn.sequence_reshape From 89b4d41d23f7bd7bb7492d1c4cb419e173685f59 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 21:38:32 +0800 Subject: [PATCH 08/12] Create sequence_reverse_cn.rst --- .../paddle/static/nn/sequence_reverse_cn.rst | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/api/paddle/static/nn/sequence_reverse_cn.rst diff --git a/docs/api/paddle/static/nn/sequence_reverse_cn.rst b/docs/api/paddle/static/nn/sequence_reverse_cn.rst new file mode 100644 index 00000000000..4c2c7f31d03 --- /dev/null +++ b/docs/api/paddle/static/nn/sequence_reverse_cn.rst @@ -0,0 +1,48 @@ +.. _cn_api_paddle_static_nn_sequence_reverse: + +sequence_reverse +------------------------------- + +.. py:function:: paddle.static.nn.sequence_reverse(x, name=None) + + +.. note:: + 该 API 仅支持带有 LoD 信息的 Tensor。 + +输入的 Tensor,在每个序列(sequence)上进行反转。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。该 OP 在构建反向 :ref:`cn_api_paddle_nn_RNN` 网络时十分有用。 + +:: + + 输入 x 是一个 Tensor: + x.lod = [[0, 2, 5]] + x.data = [[1, 2, 3, 4], + [5, 6, 7, 8], + [9, 10, 11, 12], + [13,14, 15, 16], + [17,18, 19, 20]] + x.shape = [5, 4] + + 输出 out 与 x 具有同样的 shape 和 LoD 信息: + out.lod = [[0, 2, 5]] + out.data = [[5, 6, 7, 8], + [1, 2, 3, 4], + [17,18, 19, 20], + [13,14, 15, 16], + [9, 10, 11, 12]] + out.shape = [5, 4] + + +参数 +::::::::: + + - **x** (Variable) - 输入是 LoD level 为 1 的 Tensor。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。数据类型为 float32,float64,int8,int32 或 int64。 + - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 + +返回 +::::::::: +输出在每个序列上反转后的 Tensor,数据类型和输入类型一致。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.static.nn.sequence_reverse From d6f5706131cc50afdf4f57845eece20d369b3b2e Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 21:48:08 +0800 Subject: [PATCH 09/12] Delete docs/api/paddle/static/nn/sequence_reverse_cn.rst --- .../paddle/static/nn/sequence_reverse_cn.rst | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 docs/api/paddle/static/nn/sequence_reverse_cn.rst diff --git a/docs/api/paddle/static/nn/sequence_reverse_cn.rst b/docs/api/paddle/static/nn/sequence_reverse_cn.rst deleted file mode 100644 index 4c2c7f31d03..00000000000 --- a/docs/api/paddle/static/nn/sequence_reverse_cn.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. _cn_api_paddle_static_nn_sequence_reverse: - -sequence_reverse -------------------------------- - -.. py:function:: paddle.static.nn.sequence_reverse(x, name=None) - - -.. note:: - 该 API 仅支持带有 LoD 信息的 Tensor。 - -输入的 Tensor,在每个序列(sequence)上进行反转。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。该 OP 在构建反向 :ref:`cn_api_paddle_nn_RNN` 网络时十分有用。 - -:: - - 输入 x 是一个 Tensor: - x.lod = [[0, 2, 5]] - x.data = [[1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12], - [13,14, 15, 16], - [17,18, 19, 20]] - x.shape = [5, 4] - - 输出 out 与 x 具有同样的 shape 和 LoD 信息: - out.lod = [[0, 2, 5]] - out.data = [[5, 6, 7, 8], - [1, 2, 3, 4], - [17,18, 19, 20], - [13,14, 15, 16], - [9, 10, 11, 12]] - out.shape = [5, 4] - - -参数 -::::::::: - - - **x** (Variable) - 输入是 LoD level 为 1 的 Tensor。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。数据类型为 float32,float64,int8,int32 或 int64。 - - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 - -返回 -::::::::: -输出在每个序列上反转后的 Tensor,数据类型和输入类型一致。 - -代码示例 -:::::::::::: - -COPY-FROM: paddle.static.nn.sequence_reverse From 980293774d978e5e956d42564c6d11b41c1dfb08 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 21:48:47 +0800 Subject: [PATCH 10/12] Delete docs/api/paddle/static/nn/sequence_reshape_cn.rst --- .../paddle/static/nn/sequence_reshape_cn.rst | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 docs/api/paddle/static/nn/sequence_reshape_cn.rst diff --git a/docs/api/paddle/static/nn/sequence_reshape_cn.rst b/docs/api/paddle/static/nn/sequence_reshape_cn.rst deleted file mode 100644 index ac16f4fe03e..00000000000 --- a/docs/api/paddle/static/nn/sequence_reshape_cn.rst +++ /dev/null @@ -1,48 +0,0 @@ -.. _cn_api_paddle_static_nn_sequence_reshape: - -sequence_reshape -------------------------------- - - -.. py:function:: paddle.static.nn.sequence_reshape(input, new_dim) - - -.. note:: - 该 API 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.reshape ` 。 - -在指定 ``new_dim`` 参数下,通过序列原始长度、和原始 shape 计算出新的 shape,以输出包含新维度(new_dim)下的 Tensor。目前仅支持 1-level Tensor,请确保(原长度*原维数)可以除以新的维数,且每个序列没有余数。 - -:: - - input 是一个 Tensor: - input.lod = [[0, 2, 6]] - input.data = [[1, 2], [3, 4], - [5, 6], [7, 8], - [9, 10], [11, 12]] - input.shape = [6, 2] - 设置 new_dim = 4 - 输出为 Tensor: - out.lod = [[0, 1, 3]] - - out.data = [[1, 2, 3, 4], - [5, 6, 7, 8], - [9, 10, 11, 12]] - out.shape = [3, 4] - - - -参数 -::::::::: - - - **input** (Tensor) - 维度为 :math:`[M, K]` 的二维 Tensor,且仅支持 lod_level 为 1。数据类型为 int32,int64,float32 或 float64。 - - **new_dim** (int)- 指定 reshape 后的新维度,即对输入 Tensor 重新 reshape 后的新维度。 - -返回 -::::::::: -根据新维度重新 reshape 后的 Tensor,数据类型和输入一致。 - - -代码示例 -::::::::: - -COPY-FROM: paddle.static.nn.sequence_reshape From 529104a00873f5cc1b678f80841df72440130671 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 21:49:33 +0800 Subject: [PATCH 11/12] Update Overview_cn.rst --- docs/api/paddle/static/Overview_cn.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/api/paddle/static/Overview_cn.rst b/docs/api/paddle/static/Overview_cn.rst index 6c91a70b3dc..db51c5d26b9 100644 --- a/docs/api/paddle/static/Overview_cn.rst +++ b/docs/api/paddle/static/Overview_cn.rst @@ -79,8 +79,6 @@ Executor 相关 API " :ref:`sequence_last_step ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在最后一层 lod_level 上,选取其每个序列的最后一个时间步的特征向量作为池化后的输出向量" " :ref:`sequence_pad ` ", "仅支持带有 LoD 信息的 Tensor,将同一 batch 中的序列填充到一个一致的长度(由 maxlen 指定)" " :ref:`sequence_pool ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的池化操作" - " :ref:`sequence_reshape ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的变形操作" - " :ref:`sequence_reverse ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在每个序列上进行反转" " :ref:`sequence_slice ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,实现序列切片运算" " :ref:`sequence_softmax ` ", "仅支持带有 LoD 信息的 Tensor,根据 Tensor 信息将输入的第 0 维度进行划分,在划分的每一个区间内部进行运算" From 42e8dce1e4d08021d0dc64a61be205dcc01f7195 Mon Sep 17 00:00:00 2001 From: Manyue Hu Date: Mon, 21 Apr 2025 22:04:48 +0800 Subject: [PATCH 12/12] Revert "[Docathon][Delete Deprecated API Doc No.15-16]" --- docs/api/paddle/static/Overview_cn.rst | 2 + .../paddle/static/nn/sequence_reshape_cn.rst | 48 +++++++++++++++++++ .../paddle/static/nn/sequence_reverse_cn.rst | 48 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 docs/api/paddle/static/nn/sequence_reshape_cn.rst create mode 100644 docs/api/paddle/static/nn/sequence_reverse_cn.rst diff --git a/docs/api/paddle/static/Overview_cn.rst b/docs/api/paddle/static/Overview_cn.rst index db51c5d26b9..6c91a70b3dc 100644 --- a/docs/api/paddle/static/Overview_cn.rst +++ b/docs/api/paddle/static/Overview_cn.rst @@ -79,6 +79,8 @@ Executor 相关 API " :ref:`sequence_last_step ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在最后一层 lod_level 上,选取其每个序列的最后一个时间步的特征向量作为池化后的输出向量" " :ref:`sequence_pad ` ", "仅支持带有 LoD 信息的 Tensor,将同一 batch 中的序列填充到一个一致的长度(由 maxlen 指定)" " :ref:`sequence_pool ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的池化操作" + " :ref:`sequence_reshape ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor 进行指定方式的变形操作" + " :ref:`sequence_reverse ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在每个序列上进行反转" " :ref:`sequence_slice ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,实现序列切片运算" " :ref:`sequence_softmax ` ", "仅支持带有 LoD 信息的 Tensor,根据 Tensor 信息将输入的第 0 维度进行划分,在划分的每一个区间内部进行运算" diff --git a/docs/api/paddle/static/nn/sequence_reshape_cn.rst b/docs/api/paddle/static/nn/sequence_reshape_cn.rst new file mode 100644 index 00000000000..ac16f4fe03e --- /dev/null +++ b/docs/api/paddle/static/nn/sequence_reshape_cn.rst @@ -0,0 +1,48 @@ +.. _cn_api_paddle_static_nn_sequence_reshape: + +sequence_reshape +------------------------------- + + +.. py:function:: paddle.static.nn.sequence_reshape(input, new_dim) + + +.. note:: + 该 API 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.reshape ` 。 + +在指定 ``new_dim`` 参数下,通过序列原始长度、和原始 shape 计算出新的 shape,以输出包含新维度(new_dim)下的 Tensor。目前仅支持 1-level Tensor,请确保(原长度*原维数)可以除以新的维数,且每个序列没有余数。 + +:: + + input 是一个 Tensor: + input.lod = [[0, 2, 6]] + input.data = [[1, 2], [3, 4], + [5, 6], [7, 8], + [9, 10], [11, 12]] + input.shape = [6, 2] + 设置 new_dim = 4 + 输出为 Tensor: + out.lod = [[0, 1, 3]] + + out.data = [[1, 2, 3, 4], + [5, 6, 7, 8], + [9, 10, 11, 12]] + out.shape = [3, 4] + + + +参数 +::::::::: + + - **input** (Tensor) - 维度为 :math:`[M, K]` 的二维 Tensor,且仅支持 lod_level 为 1。数据类型为 int32,int64,float32 或 float64。 + - **new_dim** (int)- 指定 reshape 后的新维度,即对输入 Tensor 重新 reshape 后的新维度。 + +返回 +::::::::: +根据新维度重新 reshape 后的 Tensor,数据类型和输入一致。 + + +代码示例 +::::::::: + +COPY-FROM: paddle.static.nn.sequence_reshape diff --git a/docs/api/paddle/static/nn/sequence_reverse_cn.rst b/docs/api/paddle/static/nn/sequence_reverse_cn.rst new file mode 100644 index 00000000000..4c2c7f31d03 --- /dev/null +++ b/docs/api/paddle/static/nn/sequence_reverse_cn.rst @@ -0,0 +1,48 @@ +.. _cn_api_paddle_static_nn_sequence_reverse: + +sequence_reverse +------------------------------- + +.. py:function:: paddle.static.nn.sequence_reverse(x, name=None) + + +.. note:: + 该 API 仅支持带有 LoD 信息的 Tensor。 + +输入的 Tensor,在每个序列(sequence)上进行反转。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。该 OP 在构建反向 :ref:`cn_api_paddle_nn_RNN` 网络时十分有用。 + +:: + + 输入 x 是一个 Tensor: + x.lod = [[0, 2, 5]] + x.data = [[1, 2, 3, 4], + [5, 6, 7, 8], + [9, 10, 11, 12], + [13,14, 15, 16], + [17,18, 19, 20]] + x.shape = [5, 4] + + 输出 out 与 x 具有同样的 shape 和 LoD 信息: + out.lod = [[0, 2, 5]] + out.data = [[5, 6, 7, 8], + [1, 2, 3, 4], + [17,18, 19, 20], + [13,14, 15, 16], + [9, 10, 11, 12]] + out.shape = [5, 4] + + +参数 +::::::::: + + - **x** (Variable) - 输入是 LoD level 为 1 的 Tensor。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。数据类型为 float32,float64,int8,int32 或 int64。 + - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 + +返回 +::::::::: +输出在每个序列上反转后的 Tensor,数据类型和输入类型一致。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.static.nn.sequence_reverse