From f8564896f6aece6336b790991619e800fc750c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Thu, 29 Dec 2022 15:13:32 +0800 Subject: [PATCH] [phi::DenseTensor] delete LoDTensor in Zh files (#5486) * fix LoDTensor * fix LoDTensor * fix LoDTensor * fix LoDTensor * fix LoDTensor * Update sequence_expand_as_cn.rst Co-authored-by: Ligoml <39876205+Ligoml@users.noreply.github.com> --- .../autograd/saved_tensors_hooks_cn.rst | 2 +- .../fluid/evaluator/DetectionMAP_cn.rst | 4 +-- .../paddle/fluid/layers/center_loss_cn.rst | 2 +- .../api/paddle/fluid/layers/prroi_pool_cn.rst | 2 +- .../layers/roi_perspective_transform_cn.rst | 16 ++++++------ docs/api/paddle/io/DataLoader_cn.rst | 6 ++--- docs/api/paddle/static/Executor_cn.rst | 2 +- docs/api/paddle/static/Overview_cn.rst | 26 +++++++++---------- docs/api/paddle/static/accuracy_cn.rst | 4 +-- docs/api/paddle/static/nn/crf_decoding_cn.rst | 8 +++--- docs/api/paddle/static/nn/embedding_cn.rst | 2 +- docs/api/paddle/static/nn/row_conv_cn.rst | 2 +- .../paddle/static/nn/sequence_concat_cn.rst | 12 ++++----- .../api/paddle/static/nn/sequence_conv_cn.rst | 10 +++---- .../static/nn/sequence_enumerate_cn.rst | 2 +- .../static/nn/sequence_expand_as_cn.rst | 12 ++++----- .../paddle/static/nn/sequence_expand_cn.rst | 12 ++++----- .../static/nn/sequence_first_step_cn.rst | 16 ++++++------ .../static/nn/sequence_last_step_cn.rst | 16 ++++++------ docs/api/paddle/static/nn/sequence_pad_cn.rst | 12 ++++----- .../api/paddle/static/nn/sequence_pool_cn.rst | 16 ++++++------ .../paddle/static/nn/sequence_reshape_cn.rst | 14 +++++----- .../paddle/static/nn/sequence_reverse_cn.rst | 10 +++---- .../paddle/static/nn/sequence_scatter_cn.rst | 6 ++--- .../paddle/static/nn/sequence_slice_cn.rst | 7 ++--- .../paddle/static/nn/sequence_softmax_cn.rst | 6 ++--- .../paddle/static/nn/sequence_unpad_cn.rst | 6 ++--- .../paddle/static/nn/sparse_embedding_cn.rst | 4 +-- .../ops/distribute_fpn_proposals_cn.rst | 2 +- 29 files changed, 120 insertions(+), 119 deletions(-) diff --git a/docs/api/paddle/autograd/saved_tensors_hooks_cn.rst b/docs/api/paddle/autograd/saved_tensors_hooks_cn.rst index 40b5b96e319..8e2332e5bf9 100644 --- a/docs/api/paddle/autograd/saved_tensors_hooks_cn.rst +++ b/docs/api/paddle/autograd/saved_tensors_hooks_cn.rst @@ -11,7 +11,7 @@ saved_tensors_hooks 用于动态图,注册一对 pack / unpack hook,用于 **参数** - - **pack_hook** (function) – 当某个算子的前向执行时,存在 Tensor 需要保留给反向计算梯度使用时, ``pack_hook`` 将会被调用。 ``pack_hook`` 可以将 Tensor 临时存放到内存或者硬盘上。 ``pack_hook`` 的输入是 1 个要被保留的 Tensor。 ``pack_hook`` 的输出是恢复被保留 Tensor 所需要的信息。当 ``PyLayerContext.save_for_backward`` 被调用时, ``pack_hook`` 也会被调用。如果一个 Tensor 是 no need buffer 的(即反向不需要数据内容,只需要数据的 meta 信息), ``pack_hook`` 则不会被调用。只有需要保留的 Tensor 是 LoDTensor, ``pack_hook`` 才会被调用。 + - **pack_hook** (function) – 当某个算子的前向执行时,存在 Tensor 需要保留给反向计算梯度使用时, ``pack_hook`` 将会被调用。 ``pack_hook`` 可以将 Tensor 临时存放到内存或者硬盘上。 ``pack_hook`` 的输入是 1 个要被保留的 Tensor。 ``pack_hook`` 的输出是恢复被保留 Tensor 所需要的信息。当 ``PyLayerContext.save_for_backward`` 被调用时, ``pack_hook`` 也会被调用。如果一个 Tensor 是 no need buffer 的(即反向不需要数据内容,只需要数据的 meta 信息), ``pack_hook`` 则不会被调用。只有需要保留的 Tensor 带有 LoD 信息, ``pack_hook`` 才会被调用。 - **unpack_hook** (function) – 当反向执行,需要用到前向保留的 Tensor 时, ``unpack_hook`` 会被调用 ``unpack_hook`` 的输入是 ``pack_hook `` 输出的用于恢复 Tensor 所需的信息。 ``unpack_hook`` 的输出是恢复后的 Tensor,这个 Tensor 的数据内容应该和 ``pack_hook`` 的输入严格一致。 **返回** diff --git a/docs/api/paddle/fluid/evaluator/DetectionMAP_cn.rst b/docs/api/paddle/fluid/evaluator/DetectionMAP_cn.rst index 518034be7b9..e13aa8360da 100644 --- a/docs/api/paddle/fluid/evaluator/DetectionMAP_cn.rst +++ b/docs/api/paddle/fluid/evaluator/DetectionMAP_cn.rst @@ -24,8 +24,8 @@ DetectionMAP - **input** (Variable) – detection 的输出结果,一个 shape=[M, 6] 的 LoDtensor。布局为[label, confidence, xmin, ymin, xmax, ymax],label 为类别标签,confidence 为置信度,xmin,ymin 为检测框左上点坐标,xmax,ymax 为检测框右下点坐标,数据类型为 float32 或 float64。 - **gt_label** (Variable) – ground truth label 的索引,它是一个形状为[N, 1]的 LoDtensor,数据类型为 float32 或 float64。 - - **gt_box** (Variable) – ground truth bounds box (bbox),是一个具有形状的 LoDTensor[N, 4]。布局是[xmin, ymin, xmax, ymax],数据类型为 float32 或 float64。 - - **gt_difficult** (Variable|None,可选) – 指定这个 ground truth 是否是一个 difficult bounding bbox,它可以是一个 shape=[N, 1]的 LoDTensor,也可以不被指定。默认设置为 None,表示所有的 ground truth 标签都不是 difficult bbox,数据类型为 float32 或 float64。 + - **gt_box** (Variable) – ground truth bounds box (bbox),是一个具有形状的 Tensor[N, 4]。布局是[xmin, ymin, xmax, ymax],数据类型为 float32 或 float64。 + - **gt_difficult** (Variable|None,可选) – 指定这个 ground truth 是否是一个 difficult bounding bbox,它可以是一个 shape=[N, 1]的 Tensor,也可以不被指定。默认设置为 None,表示所有的 ground truth 标签都不是 difficult bbox,数据类型为 float32 或 float64。 - **class_num** (int) – 检测类别的数目。 - **background_label** (int) – 背景标签的索引,背景标签将被忽略。如果设置为-1,则所有类别将被考虑,默认为 0。 - **overlap_threshold** (float) – 判断真假阳性的阈值,默认为 0.5。 diff --git a/docs/api/paddle/fluid/layers/center_loss_cn.rst b/docs/api/paddle/fluid/layers/center_loss_cn.rst index 526fed77c40..a4f4d8b614b 100644 --- a/docs/api/paddle/fluid/layers/center_loss_cn.rst +++ b/docs/api/paddle/fluid/layers/center_loss_cn.rst @@ -32,7 +32,7 @@ center_loss 返回 :::::::::::: -形状为[N x 1]的 2 维 Tensor|LoDTensor。 +形状为[N x 1]的 2 维 Tensor。 返回类型 :::::::::::: diff --git a/docs/api/paddle/fluid/layers/prroi_pool_cn.rst b/docs/api/paddle/fluid/layers/prroi_pool_cn.rst index e330192b90c..5bfe053ba37 100644 --- a/docs/api/paddle/fluid/layers/prroi_pool_cn.rst +++ b/docs/api/paddle/fluid/layers/prroi_pool_cn.rst @@ -18,7 +18,7 @@ PRROIPool 运算 :::::::::::: - **input** (Variable) - (Tensor),PRROIPoolOp 的输入。输入 Tensor 的格式是 NCHW。其中 N 是批大小 batch_size,C 是输入通道的数量,H 是输入特征图的高度,W 是特征图宽度 - - **rois** (Variable) - 要进行池化的 RoI(感兴趣区域)。应为一个形状为(num_rois, 4)的二维 LoDTensor,其 lod level 为 1。给出[[x1, y1, x2, y2], ...],(x1, y1)为左上角坐标,(x2, y2)为右下角坐标。 + - **rois** (Variable) - 要进行池化的 RoI(感兴趣区域)。应为一个形状为(num_rois, 4)的二维 Tensor,其 lod level 为 1。给出[[x1, y1, x2, y2], ...],(x1, y1)为左上角坐标,(x2, y2)为右下角坐标。 - **output_channels** (integer) - (int),输出特征图的通道数。对于共 C 个种类的对象分类任务,output_channels 应该是(C + 1),该情况仅适用于分类任务。 - **spatial_scale** (float) - (float,default 1.0),乘法空间比例因子,用于将 ROI 坐标从其输入比例转换为池化使用的比例。默认值:1.0 - **pooled_height** (integer) - (int,默认值 1),池化输出的高度。默认值:1 diff --git a/docs/api/paddle/fluid/layers/roi_perspective_transform_cn.rst b/docs/api/paddle/fluid/layers/roi_perspective_transform_cn.rst index c6f67d00880..c4ef5f0321d 100644 --- a/docs/api/paddle/fluid/layers/roi_perspective_transform_cn.rst +++ b/docs/api/paddle/fluid/layers/roi_perspective_transform_cn.rst @@ -8,23 +8,23 @@ roi_perspective_transform -该OP对RoI区域做透视变换,将不规则的RoI区域变成固定大小的矩形区域,透视变换是线性代数里面的一种基础变换。 +该 OP 对 RoI 区域做透视变换,将不规则的 RoI 区域变成固定大小的矩形区域,透视变换是线性代数里面的一种基础变换。 参数 :::::::::::: - - **input** (Variable) - 输入特征图,4-D Tensor,格式为NCHW。N是batch_size,C是输入通道数,H是特征图高度,W是特征图宽度。数据类型是float32 - - **rois** (Variable) - 感兴趣区域,2D-LoDTensor,形状是(num_rois,8),lod_level为1。其数据形式是[[x1,y1,x2,y2,x3,y3,x4,y4], ...],其中(x1,y1)是左上角坐标,(x2,y2)是右上角坐标,(x3,y3)是右下角坐标,(x4,y4)是左下角坐标。数据类型与 ``input`` 相同 + - **input** (Variable) - 输入特征图,4-D Tensor,格式为 NCHW。N 是 batch_size,C 是输入通道数,H 是特征图高度,W 是特征图宽度。数据类型是 float32 + - **rois** (Variable) - 感兴趣区域,2-D Tensor,形状是(num_rois,8)。其数据形式是[[x1,y1,x2,y2,x3,y3,x4,y4], ...],其中(x1,y1)是左上角坐标,(x2,y2)是右上角坐标,(x3,y3)是右下角坐标,(x4,y4)是左下角坐标。数据类型与 ``input`` 相同 - **transformed_height** (int) - 输出的高度 - **transformed_width** (int) – 输出的宽度 - - **spatial_scale** (float,可选) - 空间尺度因子,用于缩放ROI坐标,浮点数。默认值1.0 + - **spatial_scale** (float,可选) - 空间尺度因子,用于缩放 ROI 坐标,浮点数。默认值 1.0 返回 :::::::::::: 由三个变量构成的元组 (out, mask, transform_matrix) - - ``out`` : ``ROIPerspectiveTransformOp`` 的输出,4D-LoDTensor,形状是(num_rois,channels,transformed_height,transformed_width),lod_level为1 - - ``mask`` : ``ROIPerspectiveTransformOp`` 的掩码,4D-LoDTensor,形状是(num_rois,1,transformed_height,transformed_width),lod_level为1 - - ``transform_matrix`` : ``ROIPerspectiveTransformOp`` 的转换矩阵,2D-LoDTensor,形状是(num_rois,9),lod_level为1 + - ``out`` : ``ROIPerspectiveTransformOp`` 的输出,4D-LoDTensor,形状是(num_rois,channels,transformed_height,transformed_width),lod_level 为 1 + - ``mask`` : ``ROIPerspectiveTransformOp`` 的掩码,4D-LoDTensor,形状是(num_rois,1,transformed_height,transformed_width),lod_level 为 1 + - ``transform_matrix`` : ``ROIPerspectiveTransformOp`` 的转换矩阵,2D-LoDTensor,形状是(num_rois,9),lod_level 为 1 返回类型 :::::::::::: @@ -33,4 +33,4 @@ roi_perspective_transform 代码示例 :::::::::::: -COPY-FROM: paddle.fluid.layers.roi_perspective_transform \ No newline at end of file +COPY-FROM: paddle.fluid.layers.roi_perspective_transform diff --git a/docs/api/paddle/io/DataLoader_cn.rst b/docs/api/paddle/io/DataLoader_cn.rst index de8cab80023..7e9cf9d4b29 100644 --- a/docs/api/paddle/io/DataLoader_cn.rst +++ b/docs/api/paddle/io/DataLoader_cn.rst @@ -139,9 +139,9 @@ from_generator(feed_list=None, capacity=None, use_double_buffer=True, iterable=T - **capacity** (int) - DataLoader 对象内部维护队列的容量大小。单位是 batch 数量。若 reader 读取速度较快,建议设置较大的 capacity 值。 - **use_double_buffer** (bool,可选) - 是否使用 ``double_buffer_reader``。若 use_double_buffer=True,DataLoader 会异步地预读取下一个 batch 的数据,可加速数据读取过程,但同时会占用少量的 CPU/GPU 存储,即一个 batch 输入数据的存储空间。 - **iterable** (bool,可选) - 所创建的 DataLoader 对象是否可迭代。 - - **return_list** (bool,可选) - 每个设备上的数据是否以 list 形式返回。仅在 iterable = True 模式下有效。若 return_list = False,每个设备上的返回数据均是 str -> LoDTensor 的映射表,其中映射表的 key 是每个输入变量的名称。若 return_list = True,则每个设备上的返回数据均是 list(LoDTensor)。推荐在静态图模式下使用 return_list = False,在动态图模式下使用 return_list = True。 - - **use_multiprocess** (bool,可选) - 设置是否是用多进程加速动态图的数据载入过程。**注意**:该参数的设置仅在动态图模式下有效,在静态图模式下,该参数设置与否均无任何影响。默认值为 False。 - - **drop_last** (bool,可选) - 是否丢弃最后的不足 CPU/GPU 设备数的批次。默认值为 True。在网络训练时,用户不能设置 drop_last=False,此时所有 CPU/GPU 设备均应从 DataLoader 中读取到数据。在网络预测时,用户可以设置 drop_last=False,此时最后不足 CPU/GPU 设备数的批次可以进行预测。 + - **return_list** (bool,可选) - 每个设备上的数据是否以 list 形式返回。仅在 iterable = True 模式下有效。若 return_list = False,每个设备上的返回数据均是 str -> Tensor 的映射表,其中映射表的 key 是每个输入变量的名称。若 return_list = True,则每个设备上的返回数据均是 list(Tensor)。推荐在静态图模式下使用 return_list = False,在动态图模式下使用 return_list = True。 + - **use_multiprocess** (bool,可选) - 设置是否是用多进程加速动态图的数据载入过程。注意:该参数的设置仅在动态图模式下有效,在静态图模式下,该参数设置与否均无任何影响。默认值为 False。 + - **drop_last** (bool,可选):是否丢弃最后的不足 CPU/GPU 设备数的批次。默认值为 True。在网络训练时,用户不能设置 drop_last=False,此时所有 CPU/GPU 设备均应从 DataLoader 中读取到数据。在网络预测时,用户可以设置 drop_last=False,此时最后不足 CPU/GPU 设备数的批次可以进行预测。 **返回** diff --git a/docs/api/paddle/static/Executor_cn.rst b/docs/api/paddle/static/Executor_cn.rst index 0ff00eb4c3a..2d3901842b9 100644 --- a/docs/api/paddle/static/Executor_cn.rst +++ b/docs/api/paddle/static/Executor_cn.rst @@ -59,7 +59,7 @@ run(program=None, feed=None, fetch_list=None, feed_var_name='feed', fetch_var_na - **feed_var_name** (str) – 该参数表示数据输入算子(feed operator)的输入变量名称。默认为:"feed"。 - **fetch_var_name** (str) – 该参数表示结果获取算子(fetch operator)的输出变量名称。默认为:"fetch"。 - **scope** (Scope) – 该参数表示执行当前 program 所使用的作用域,用户可以为不同的 program 指定不同的作用域。默认值:paddle.static.global_scope()。 - - **return_numpy** (bool) – 该参数表示是否将返回的计算结果(fetch list 中指定的变量)转化为 numpy;如果为 False,则每个变量返回的类型为 LoDTensor,否则返回变量的类型为 numpy.ndarray。默认为:True。 + - **return_numpy** (bool) – 该参数表示是否将返回的计算结果(fetch list 中指定的变量)转化为 numpy;如果为 False,则每个变量返回的类型为 Tensor,否则返回变量的类型为 numpy.ndarray。默认为:True。 - **use_program_cache** (bool) – 该参数表示是否对输入的 Program 进行缓存。如果该参数为 True,在以下情况时,模型运行速度可能会更快:输入的 program 为 ``paddle.static.Program``,并且模型运行过程中,调用该接口的参数(program、 feed 变量名和 fetch_list 变量)名始终不变。默认为:False。 - **return_merged** (bool) – 该参数表示是否按照执行设备维度将返回的计算结果(fetch list 中指定的变量)进行合并。如果 ``return_merged`` 设为 False,返回值类型是一个 Tensor 的二维列表( ``return_numpy`` 设为 Fasle 时)或者一个 numpy.ndarray 的二维列表( ``return_numpy`` 设为 True 时)。如果 ``return_merged`` 设为 True,返回值类型是一个 Tensor 的一维列表( ``return_numpy`` 设为 Fasle 时)或者一个 numpy.ndarray 的一维列表( ``return_numpy`` 设为 True 时)。更多细节请参考示例代码 2。如果返回的计算结果是变长的,请设置 ``return_merged`` 为 False,即不按照执行设备维度合并返回的计算结果。该参数的默认值为 True,但这仅是为了兼容性考虑,在未来的版本中默认值可能会更改为 False。 - **use_prune** (bool) - 该参数表示输入 Program 是否会被裁剪。如果该参数为 True,会根据 feed 和 fetch_list 裁剪 Program,这意味着对生成 fetch_list 没有必要的算子和变量会被裁剪掉。默认为 False,即算子和变量在运行过程不会被裁剪。注意如果 Optimizer.minimize()返回的 tuple 被作为 fetch_list 参数,那么 use_prune 会被重载为 True 并且 Program 会被裁剪。 diff --git a/docs/api/paddle/static/Overview_cn.rst b/docs/api/paddle/static/Overview_cn.rst index a7d787a5183..50e799742e7 100644 --- a/docs/api/paddle/static/Overview_cn.rst +++ b/docs/api/paddle/static/Overview_cn.rst @@ -77,19 +77,19 @@ Executor 相关 API " :ref:`row_conv ` ", "行卷积" " :ref:`spectral_norm ` ", "Spectral Normalization 方法" " :ref:`switch_case ` ", "类似于 c++的 switch/case" - " :ref:`sequence_concat ` ", "仅支持 LoDTensor ,通过 LoDTensor 的 LoD 信息将输入的多个 LoDTensor 进行连接,输出连接后的 LoDTensor" - " :ref:`sequence_conv ` ", "仅支持 LoDTensor ,在给定的卷积参数下,对输入的变长序列 LoDTensor 进行卷积操作" - " :ref:`sequence_enumerate ` ", "仅支持 LoDTensor ,枚举形状为 [d_1, 1] 的输入序列所有长度为 win_size 的子序列,生成一个形状为 [d_1, win_size] 的新序列,需要时以 pad_value 填充" - " :ref:`sequence_expand ` ", "仅支持 LoDTensor ,根据输入 y 的第 ref_level 层 lod 对输入 x 进行扩展" - " :ref:`sequence_expand_as ` ", "仅支持 LoDTensor ,根据输入 y 的第 0 级 lod 对输入 x 进行扩展" - " :ref:`sequence_first_step ` ", "仅支持 LoDTensor ,对输入的 LoDTensor,在最后一层 lod_level 上,选取其每个序列的第一个时间步的特征向量作为池化后的输出向量" - " :ref:`sequence_last_step ` ", "仅支持 LoDTensor ,对输入的 LoDTensor,在最后一层 lod_level 上,选取其每个序列的最后一个时间步的特征向量作为池化后的输出向量" - " :ref:`sequence_pad ` ", "仅支持 LoDTensor ,将同一 batch 中的序列填充到一个一致的长度(由 maxlen 指定)" - " :ref:`sequence_pool ` ", "仅支持 LoDTensor ,对输入的 LoDTensor 进行指定方式的池化操作" - " :ref:`sequence_reshape ` ", "仅支持 LoDTensor ,对输入的 LoDTensor 进行指定方式的变形操作" - " :ref:`sequence_reverse ` ", "仅支持 LoDTensor ,对输入的 LoDTensor,在每个序列上进行反转" - " :ref:`sequence_slice ` ", "仅支持 LoDTensor ,对输入的 LoDTensor,实现序列切片运算" - " :ref:`sequence_softmax ` ", "仅支持 LoDTensor ,根据 LoDTensor 信息将输入的第 0 维度进行划分,在划分的每一个区间内部进行运算" + " :ref:`sequence_concat ` ", "仅支持带有 LoD 信息的 Tensor ,通过 Tensor 的 LoD 信息将输入的多个 Tensor 进行连接,输出连接后的 Tensor" + " :ref:`sequence_conv ` ", "仅支持带有 LoD 信息的 Tensor,在给定的卷积参数下,对输入的变长序列 Tensor 进行卷积操作" + " :ref:`sequence_enumerate ` ", "仅支持带有 LoD 信息的 Tensor,枚举形状为 [d_1, 1] 的输入序列所有长度为 win_size 的子序列,生成一个形状为 [d_1, win_size] 的新序列,需要时以 pad_value 填充" + " :ref:`sequence_expand ` ", "仅支持带有 LoD 信息的 Tensor,根据输入 y 的第 ref_level 层 lod 对输入 x 进行扩展" + " :ref:`sequence_expand_as ` ", "仅支持带有 LoD 信息的 Tensor,根据输入 y 的第 0 级 lod 对输入 x 进行扩展" + " :ref:`sequence_first_step ` ", "仅支持带有 LoD 信息的 Tensor,对输入的 Tensor,在最后一层 lod_level 上,选取其每个序列的第一个时间步的特征向量作为池化后的输出向量" + " :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 维度进行划分,在划分的每一个区间内部进行运算" .. _about_io: diff --git a/docs/api/paddle/static/accuracy_cn.rst b/docs/api/paddle/static/accuracy_cn.rst index 8259e452fef..c23d22e86c3 100755 --- a/docs/api/paddle/static/accuracy_cn.rst +++ b/docs/api/paddle/static/accuracy_cn.rst @@ -15,8 +15,8 @@ accuracy layer。参考 https://en.wikipedia.org/wiki/Precision_and_recall 参数 :::::::::::: - - **input** (Tensor|LoDTensor)-数据类型为 float32,float64。输入为网络的预测值。shape 为 ``[sample_number, class_dim]`` 。 - - **label** (Tensor|LoDTensor)-数据类型为 int64,int32。输入为数据集的标签。shape 为 ``[sample_number, 1]`` 。 + - **input** (Tensor)-数据类型为 float32,float64。输入为网络的预测值。shape 为 ``[sample_number, class_dim]`` 。 + - **label** (Tensor)-数据类型为 int64,int32。输入为数据集的标签。shape 为 ``[sample_number, 1]`` 。 - **k** (int64|int32) - 取每个类别中 k 个预测值用于计算。 - **correct** (int64|int32)-正确预测值的个数。 - **total** (int64|int32)-总共的预测值。 diff --git a/docs/api/paddle/static/nn/crf_decoding_cn.rst b/docs/api/paddle/static/nn/crf_decoding_cn.rst index 80046ff3455..e5d64b37917 100644 --- a/docs/api/paddle/static/nn/crf_decoding_cn.rst +++ b/docs/api/paddle/static/nn/crf_decoding_cn.rst @@ -13,18 +13,18 @@ crf_decoding 这个层运算的结果会随着输入 ``Label`` 的有无而改变: - 1. ``Label`` 非 None 的情况,在实际训练中时常发生。此时本层会协同 :ref:`cn_api_fluid_layers_chunk_eval` 工作。在 LoDTensor 模式下,本层会返回一行形为 [N X 1] 的向量,在 padding 模式下,返回形状则为 [B x S],其中值为 0 的部分代表该 label 不适合作为对应结点的标注,值为 1 的部分则反之。此类型的输出可以直接作为 :ref:`cn_api_fluid_layers_chunk_eval` 算子的输入; + 1. ``Label`` 非 None 的情况,在实际训练中时常发生。此时本层会协同 :ref:`cn_api_fluid_layers_chunk_eval` 工作。在 LoD 模式下,本层会返回一行形为 [N X 1] 的向量,在 padding 模式下,返回形状则为 [B x S],其中值为 0 的部分代表该 label 不适合作为对应结点的标注,值为 1 的部分则反之。此类型的输出可以直接作为 :ref:`cn_api_fluid_layers_chunk_eval` 算子的输入; 2. 当没有 ``Label`` 时,该函数会执行标准解码过程; -(没有 ``Label`` 时)该运算返回一个形状为 [N X 1] 或 [B x S] 的向量,此处的形状取决于输入是 LoDTensor 还是普通 Tensor,其中元素取值范围为 0 ~ 最大标注个数-1,分别为预测出的标注(tag)所在的索引。 +(没有 ``Label`` 时)该运算返回一个形状为 [N X 1] 或 [B x S] 的向量,此处的形状取决于输入是否为带有 LoD 信息的 Tensor,其中元素取值范围为 0 ~ 最大标注个数-1,分别为预测出的标注(tag)所在的索引。 参数 :::::::::::: - - **input** (Tensor) — 一个形为 [N x D] 的 LoDTensor,其中 N 是 mini-batch 的大小,D 是标注(tag) 的总数;或者形为 [B x S x D] 的普通 Tensor,B 是批次大小,S 是序列最大长度,D 是标注的总数。该输入是 :ref:`cn_api_fluid_layers_linear_chain_crf`` 的 unscaled emission weight matrix (未标准化的发射权重矩阵)。数据类型为 float32 或者 float64。 + - **input** (Tensor) — 一个形为 [N x D] 的 Tensor,其中 N 是 mini-batch 的大小,D 是标注(tag) 的总数;或者形为 [B x S x D] 的普通 Tensor,B 是批次大小,S 是序列最大长度,D 是标注的总数。该输入是 :ref:`cn_api_fluid_layers_linear_chain_crf`` 的 unscaled emission weight matrix (未标准化的发射权重矩阵)。数据类型为 float32 或者 float64。 - **param_attr** (ParamAttr,可选):指定权重参数属性的对象。默认值为 None,表示使用默认的权重参数属性。具体用法请参见 :ref:`cn_api_guide_ParamAttr` 。 - - **label** (Tensor,可选) — 形为 [N x 1] 的正确标注(ground truth)(LoDTensor 模式),或者形状为 [B x S]。有关该参数的更多信息,请详见上述描述。数据类型为 int64。 + - **label** (Tensor,可选) — 形为 [N x 1] 的正确标注(ground truth)(LoD 模式),或者形状为 [B x S]。有关该参数的更多信息,请详见上述描述。数据类型为 int64。 - **length** (Tensor,可选) — 形状为 [B x 1],表示输入序列的真实长度。该输入非 None,表示该层工作在 padding 模式下,即 ``input`` 和 ``label`` 都是带 padding 的普通 Tensor。数据类型为 int64。 返回 diff --git a/docs/api/paddle/static/nn/embedding_cn.rst b/docs/api/paddle/static/nn/embedding_cn.rst index 58509bd9cd0..b9cc2d0b098 100644 --- a/docs/api/paddle/static/nn/embedding_cn.rst +++ b/docs/api/paddle/static/nn/embedding_cn.rst @@ -41,7 +41,7 @@ input 中的 id 必须满足 ``0 =< id < size[0]``,否则程序会抛异常退 Case 2: - input 是 lod level 为 1 的 LoDTensor,且 padding_idx = 0 + input 是 lod level 为 1 的 Tensor,且 padding_idx = 0 input.lod = [[2, 3]] input.data = [[1], [3], [2], [4], [0]] input.shape = [5, 1] diff --git a/docs/api/paddle/static/nn/row_conv_cn.rst b/docs/api/paddle/static/nn/row_conv_cn.rst index f3cf35e762c..54143720c1c 100644 --- a/docs/api/paddle/static/nn/row_conv_cn.rst +++ b/docs/api/paddle/static/nn/row_conv_cn.rst @@ -30,7 +30,7 @@ row_conv 参数 :::::::::::: - - **input** (Tensor) - 支持输入为 LodTensor 和 Tensor,输入类型可以是[float32, float64],它支持可变时间长度的输入序列。当输入 input 为 LodTensor 时,其内部 Tensor 是一个具有形状(T x N)的矩阵,其中 T 是这个 mini batch 中的总的 timestep,N 是输入数据维数。当输入 input 为 Tensor 时,其形状为(B x T x N)的三维矩阵,B 为 mini batch 大小,T 为每个 batch 输入中的最大 timestep,N 是输入数据维数。当输入 input 为 LoDTensor,形状为[9, N],LoD 信息为[2, 3, 4],等价于输入 input 为形状是[3, 4, N]的 Tensor。 + - **input** (Tensor) - 支持输入为 LodTensor 和 Tensor,输入类型可以是[float32, float64],它支持可变时间长度的输入序列。当输入 input 为 LodTensor 时,其内部 Tensor 是一个具有形状(T x N)的矩阵,其中 T 是这个 mini batch 中的总的 timestep,N 是输入数据维数。当输入 input 为 Tensor 时,其形状为(B x T x N)的三维矩阵,B 为 mini batch 大小,T 为每个 batch 输入中的最大 timestep,N 是输入数据维数。 - **future_context_size** (int) - 下文大小。请注意,卷积核的 shape 是[future_context_size + 1, N],N 和输入 input 的数据维度 N 保持一致。 - **param_attr** (ParamAttr) - 参数的属性,包括名称、初始化器等。 - **act** (str) - 非线性激活函数。 diff --git a/docs/api/paddle/static/nn/sequence_concat_cn.rst b/docs/api/paddle/static/nn/sequence_concat_cn.rst index dacde811732..ca651c9c1fd 100644 --- a/docs/api/paddle/static/nn/sequence_concat_cn.rst +++ b/docs/api/paddle/static/nn/sequence_concat_cn.rst @@ -7,13 +7,13 @@ sequence_concat .. py:function:: paddle.static.nn.sequence_concat(input, name=None) .. note:: -该 OP 的输入只能是 LoDTensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.concat ` 。 +该 OP 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是一般的 Tensor 类型,请使用 :ref:`paddle.concat ` 。 -**该 OP 仅支持 LoDTensor**,通过 LoDTensor 的 LoD 信息将输入的多个 LoDTensor 进行连接(concat),输出连接后的 LoDTensor。 +**该 OP 仅支持带有 LoD 信息的 Tensor**,通过 LoD 信息将输入的多个 Tensor 进行连接(concat),输出连接后的 Tensor。 :: - input 是由多个 LoDTensor 组成的 list: + input 是由多个带有 LoD 信息的 Tensor 组成的 list: input = [x1, x2] 其中: x1.lod = [[0, 3, 5]] @@ -25,7 +25,7 @@ sequence_concat x2.shape = [4, 1] 且必须满足:len(x1.lod[0]) == len(x2.lod[0]) - 输出为 LoDTensor: + 输出为 Tensor: out.lod = [[0, 3+2, 5+4]] out.data = [[1], [2], [3], [6], [7], [4], [5], [8], [9]] out.shape = [9, 1] @@ -34,12 +34,12 @@ sequence_concat 参数 ::::::::: - - **input** (list of Variable) – 多个 LoDTensor 组成的 list,要求每个输入 LoDTensor 的 LoD 长度必须一致。数据类型为 float32、float64 或 int64。 + - **input** (list of Variable) – 多个带有 LoD 信息的 Tensor 组成的 list,要求每个输入 Tensor 的 LoD 长度必须一致。数据类型为 float32、float64 或 int64。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: -Tensor,输出连接后的 LoDTensor,数据类型和输入一致。 +Tensor,输出连接后的 Tensor,数据类型和输入一致。 代码示例 ::::::::: diff --git a/docs/api/paddle/static/nn/sequence_conv_cn.rst b/docs/api/paddle/static/nn/sequence_conv_cn.rst index bdaaf42c6bb..21bdce6e4dd 100644 --- a/docs/api/paddle/static/nn/sequence_conv_cn.rst +++ b/docs/api/paddle/static/nn/sequence_conv_cn.rst @@ -7,17 +7,17 @@ sequence_conv .. py:function:: paddle.static.nn.sequence_conv(input, num_filters, filter_size=3, filter_stride=1, padding=True, padding_start=None, bias_attr=None, param_attr=None, act=None, name=None) .. note:: -1. 该 API 的输入只能是 LoDTensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.nn.functional.conv2d ` 。 +1. 该 API 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是普通的 Tensor 类型,请使用 :ref:`paddle.nn.functional.conv2d ` 。 2. 参数 ``padding`` 为无用参数,将在未来的版本中被移除。 -在给定的卷积参数下(如卷积核数目、卷积核大小等),对输入的变长序列(sequence)LoDTensor 进行卷积操作。默认情况下,该 OP 会自适应地在每个输入序列的两端等长地填充全 0 数据,以确保卷积后的序列输出长度和输入长度一致。支持通过配置 ``padding_start`` 参数来指定序列填充的行为。 +在给定的卷积参数下(如卷积核数目、卷积核大小等),对输入的变长序列(sequence)Tensor 进行卷积操作。默认情况下,该 OP 会自适应地在每个输入序列的两端等长地填充全 0 数据,以确保卷积后的序列输出长度和输入长度一致。支持通过配置 ``padding_start`` 参数来指定序列填充的行为。 :: 这里详细介绍数据填充操作的细节: 对于一个 min-batch 为 2 的变长序列输入,分别包含 3 个、1 个时间步(time_step), - 假设输入 input 是一个[4, N]的 float 类型 LoDTensor,为了方便,这里假设 N = 2 + 假设输入 input 是一个[4, N]的 float 类型 Tensor,为了方便,这里假设 N = 2 input.data = [[1, 1], [2, 2], [3, 3], @@ -52,7 +52,7 @@ sequence_conv 参数 ::::::::: - - **input** (Variable) - 维度为 :math:`(M, K)` 的二维 LoDTensor,仅支持 lod_level 为 1。其中 M 是 mini-batch 的总时间步数,K 是输入的 ``hidden_size`` 特征维度。数据类型为 float32 或 float64。 + - **input** (Variable) - 维度为 :math:`(M, K)` 的二维 Tensor,仅支持 lod_level 为 1。其中 M 是 mini-batch 的总时间步数,K 是输入的 ``hidden_size`` 特征维度。数据类型为 float32 或 float64。 - **num_filters** (int) - 滤波器的数量。 - **filter_size** (int,可选) - 滤波器的高度(H);不支持指定滤波器宽度(W),宽度固定取值为输入的 ``hidden_size``。默认值为 3。 - **filter_stride** (int,可选) - 滤波器每次移动的步长。目前只支持取值为 1,默认为 1。 @@ -66,7 +66,7 @@ sequence_conv 返回 ::::::::: -和输入序列等长的 LoDTensor,数据类型和输入一致,为 float32 或 float64。 +和输入序列等长的 Tensor,数据类型和输入一致,为 float32 或 float64。 代码示例 ::::::::: diff --git a/docs/api/paddle/static/nn/sequence_enumerate_cn.rst b/docs/api/paddle/static/nn/sequence_enumerate_cn.rst index 5a17f46e9c4..e30028dfb1f 100644 --- a/docs/api/paddle/static/nn/sequence_enumerate_cn.rst +++ b/docs/api/paddle/static/nn/sequence_enumerate_cn.rst @@ -36,7 +36,7 @@ sequence_enumerate 返回 ::::::::: -枚举序列,形状为 ``[d_1, win_size]`` ,lod_level 为 1 的 LoDTensor。数据类型与输入 ``input`` 一致。 +枚举序列,形状为 ``[d_1, win_size]`` ,lod_level 为 1 的 Tensor。数据类型与输入 ``input`` 一致。 diff --git a/docs/api/paddle/static/nn/sequence_expand_as_cn.rst b/docs/api/paddle/static/nn/sequence_expand_as_cn.rst index 4fcd7f641db..6b9ee8595bd 100644 --- a/docs/api/paddle/static/nn/sequence_expand_as_cn.rst +++ b/docs/api/paddle/static/nn/sequence_expand_as_cn.rst @@ -18,13 +18,13 @@ Sequence Expand As Layer,该 OP 根据输入 ``y`` 的第 0 级 lod 对输入 例 1: 假设,有 4 个长度维 1 的序列[a]、[b]、[c]和[d],现在要将其扩展为长度是 3、3、1、1 的序列[a][a][a]、[b][b][b]、[c]和[d]。 显然,扩展后的序列 lod 为[0, 3, 6, 7, 8],则: - 给定输入一维 LoDTensor x + 给定输入一维 Tensor x x.data = [[a], [b], [c], [d]] x.dims = [4, 1] 和输入 y y.lod = [[3, 3, 1, 1]] #为了便于理解这里用基于长度 lod 表示 - 经过 sequence_expand_as 运算,得到输出 1 级 LoDTensor out + 经过 sequence_expand_as 运算,得到输出 1 级 Tensor out out.lod = [[0, 3, 6, 7, 8]] #基于偏移的 lod,等价于基于长度的[[3, 3, 1, 1]] out.data = [[a], [a], [a], [b], [b], [b], [c], [d]] out.dims = [8, 1] @@ -34,13 +34,13 @@ Sequence Expand As Layer,该 OP 根据输入 ``y`` 的第 0 级 lod 对输入 :: 例 2: - 设定与例 1 类似,给定输入一维 LoDTensor x: + 设定与例 1 类似,给定输入一维 Tensor x: x.data = [[a, b], [c, d], [e, f]] x.dims = [3, 2] 和输入 y: y.lod = [[2, 1, 3]] #为了便于理解这里用基于长度 lod 表示 - 输出为 1 级 LoDTensor: + 输出为 1 级 Tensor: out.lod = [[0, 2, 3, 6]] #基于偏移的 lod,等价于基于长度的[[2, 1, 3]] out.data = [[a, b], [a, b] [c, d], [e, f], [e, f], [e, f]] out.dims = [6, 2] @@ -52,12 +52,12 @@ Sequence Expand As Layer,该 OP 根据输入 ``y`` 的第 0 级 lod 对输入 ::::::::: - **x** (Variable) - 输入变量,维度为 :math:`[M, K]` 的二维 Tensor,第一维必须与输入 ``y`` 的第 0 层 lod 大小相同,且仅支持 lod_level 为 1。数据类型支持 int32,int64,float32 或 float64。 - - **y** (Variable) - 输入变量,LoDTensor,lod level 必须为 1。 + - **y** (Variable) - 输入变量,Tensor,lod level 必须为 1。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: -扩展变量,维度为 :math:`[N, K]` 的二维 LoDTensor,N 由输入 ``y`` 的 lod 决定,且仅支持 lod_level 为 1。数据类型与输入 ``x`` 一致。 +扩展变量,维度为 :math:`[N, K]` 的二维 Tensor,N 由输入 ``y`` 的 lod 决定,且仅支持 lod_level 为 1。数据类型与输入 ``x`` 一致。 代码示例 ::::::::: diff --git a/docs/api/paddle/static/nn/sequence_expand_cn.rst b/docs/api/paddle/static/nn/sequence_expand_cn.rst index 626a2bb451d..44e171af502 100644 --- a/docs/api/paddle/static/nn/sequence_expand_cn.rst +++ b/docs/api/paddle/static/nn/sequence_expand_cn.rst @@ -20,7 +20,7 @@ sequence_expand 例 1: 假设两个长度为 2 的序列[a][b]和[c][d],欲将其扩展为 4 个长度为 2 的序列[a][b]、[a][b]、[c][d]、[c][d]。 序列[a][b]扩展 2 次,[c][d]扩展 2 次,扩展所需依据的 lod 为[2, 2],则: - 给定输入一维 LoDTensor x + 给定输入一维 Tensor x x.lod = [[2, 2]] #表示两个序列的长度为 2,为了便于理解这里用基于长度 lod 表示 x.data = [[a], [b], [c], [d]] x.dims = [4, 1] @@ -29,7 +29,7 @@ sequence_expand [3, 3, 1, 1]] #第 1 层 lod,注意,因为指定 ref_level 为 0,所以这一层与运算无关 指定 ref_level = 0,依据 y 的第 0 层 lod 进行扩展, - 经过 sequence_expand,输出为 1 级 LoDTensor out + 经过 sequence_expand,输出为 1 级 Tensor out out.lod = [[0, 2, 4, 6, 8]] #基于偏移的 lod,等价于基于长度的[[2, 2, 2, 2]] out.data = [[a], [b], [a], [b], [c], [d], [c], [d]] out.dims = [8, 1] @@ -39,14 +39,14 @@ sequence_expand 例 2: 假设有 3 个长度维 1 的序列[a]、[b]、[c],现在要将其扩展为长度是 2、0、3 的序列[a][a]、[c][c][c]。 显然,扩展后的序列 lod 为[2, 0, 3],则: - 给定输入一维 LoDTensor x + 给定输入一维 Tensor x x.data = [[a], [b], [c]] x.dims = [3, 1] 和输入 y y.lod = [[2, 0, 3]] 默认 ref_level = -1 - 经过 sequence_expand,输出为 1 级 LoDTensor out + 经过 sequence_expand,输出为 1 级 Tensor out out.data = [[a], [a], [c], [c], [c]] out.dims = [5, 1] @@ -54,13 +54,13 @@ sequence_expand ::::::::: - **x** (Variable) - 输入变量,维度为 :math:`[M, K]` ,lod level 至多 1 的二维 Tensor。数据类型支持 int32,int64,float32 或 float64。 - - **y** (Variable) - 输入变量,lod level 至少为 1 的 LoDTensor。数据类型不限。 + - **y** (Variable) - 输入变量,lod level 至少为 1 的 Tensor。数据类型不限。 - **ref_level** (int,可选) - 扩展 ``x`` 所依据的 ``y`` 的 lod 层。默认值-1,表示 lod 的最后一层。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: -扩展变量,维度为 :math:`[N, K]` 的 LoDTensor,N 由输入 ``x`` 和 ``y`` 的 lod 共同决定。数据类型与输入 ``x`` 一致。 +扩展变量,维度为 :math:`[N, K]` 的 Tensor,N 由输入 ``x`` 和 ``y`` 的 lod 共同决定。数据类型与输入 ``x`` 一致。 代码示例 ::::::::: diff --git a/docs/api/paddle/static/nn/sequence_first_step_cn.rst b/docs/api/paddle/static/nn/sequence_first_step_cn.rst index 0a886d2f540..009f268d3c5 100644 --- a/docs/api/paddle/static/nn/sequence_first_step_cn.rst +++ b/docs/api/paddle/static/nn/sequence_first_step_cn.rst @@ -7,27 +7,27 @@ sequence_first_step .. py:function:: paddle.static.nn.sequence_first_step(input) .. note:: -该 API 仅支持 LoDTensor 类型的输入。 +该 API 仅支持带有 LoD 信息的 Tensor 类型的输入。 -对输入的 LoDTensor,在最后一层 lod_level 上,选取其每个序列(sequence)的第一个时间步(time_step)的特征向量作为池化后的输出向量。 +对输入的 Tensor,在最后一层 lod_level 上,选取其每个序列(sequence)的第一个时间步(time_step)的特征向量作为池化后的输出向量。 :: Case 1: - input 是 1-level LoDTensor: + input 是 1-level Tensor: input.lod = [[0, 2, 5, 7]] input.data = [[1.], [3.], [2.], [4.], [6.], [5.], [1.]] input.shape = [7, 1] - 输出为 LoDTensor: + 输出为 Tensor: out.shape = [3, 1] 且 out.shape[0] == len(x.lod[-1]) == 3 out.data = [[1.], [2.], [5.]], where 1.=first(1., 3.), 2.=first(2., 4., 6.), 5.=first(5., 1.) Case 2: - input 是 2-level 的 LoDTensor,包含 3 个长度分别为[2, 0, 3]的序列,其中中间的 0 表示序列为空。 + input 是 2-level 的 Tensor,包含 3 个长度分别为[2, 0, 3]的序列,其中中间的 0 表示序列为空。 第一个长度为 2 的序列包含 2 个长度分别为[1, 2]的子序列; 最后一个长度为 3 的序列包含 3 个长度分别为[1, 0, 3]的子序列。 input.lod = [[0, 2, 2, 5], [0, 1, 3, 4, 4, 7]] @@ -35,7 +35,7 @@ sequence_first_step input.shape = [7, 1] 将根据最后一层的 lod 信息[0, 1, 3, 4, 4, 7]进行池化操作,且 pad_value = 0.0 - 输出为 LoDTensor: + 输出为 Tensor: out.shape= [5, 1] out.lod = [[0, 2, 2, 5]] 其中 out.shape[0] == len(x.lod[-1]) == 5 @@ -44,11 +44,11 @@ sequence_first_step 参数 ::::::::: -**input** (Variable)- 类型为 LoDTensor 的输入序列,仅支持 lod_level 不超过 2 的 LoDTensor,数据类型为 float32。 +**input** (Variable)- 类型为 Tensor 的输入序列,仅支持 lod_level 不超过 2 的 Tensor,数据类型为 float32。 返回 ::::::::: -每个输入序列中的第一个 step 的特征向量组成的 LoDTensor,数据类型为 float32。 +每个输入序列中的第一个 step 的特征向量组成的 Tensor,数据类型为 float32。 代码示例 diff --git a/docs/api/paddle/static/nn/sequence_last_step_cn.rst b/docs/api/paddle/static/nn/sequence_last_step_cn.rst index f6bf3cded41..a932ba76b60 100644 --- a/docs/api/paddle/static/nn/sequence_last_step_cn.rst +++ b/docs/api/paddle/static/nn/sequence_last_step_cn.rst @@ -8,20 +8,20 @@ sequence_last_step .. note:: -该 API 仅支持 LoDTensor 类型的输入。 +该 API 仅支持带有 LoD 信息的 Tensor 类型的输入。 -对输入的 LoDTensor,在最后一层 lod_level 上,选取其每个序列(sequence)的最后一个时间步(time-step)的特征向量作为池化后的输出向量。 +对输入的 Tensor,在最后一层 lod_level 上,选取其每个序列(sequence)的最后一个时间步(time-step)的特征向量作为池化后的输出向量。 :: Case 1: - input 是 1-level 的 LoDTensor: + input 是 1-level 的 Tensor: input.lod = [[0, 2, 5, 7]] input.data = [[1.], [3.], [2.], [4.], [6.], [5.], [1.]] input.shape = [7, 1] - 输出为 LoDTensor: + 输出为 Tensor: out.shape = [3, 1] 且 out.shape[0] == len(x.lod[-1]) == 3 @@ -29,7 +29,7 @@ sequence_last_step Case 2: - input 是 2-level 的 LoDTensor,包含 3 个长度分别为[2, 0, 3]的序列,其中中间的 0 表示序列为空。 + input 是 2-level 的 Tensor,包含 3 个长度分别为[2, 0, 3]的序列,其中中间的 0 表示序列为空。 第一个长度为 2 的序列包含 2 个长度分别为[1, 2]的子序列; 最后一个长度为 3 的序列包含 3 个长度分别为[1, 0, 3]的子序列。 input.lod = [[0, 2, 2, 5], [0, 1, 3, 4, 4, 7]] @@ -37,7 +37,7 @@ sequence_last_step input.shape = [7, 1] 将根据最后一层的 lod 信息[0, 1, 3, 4, 4, 7]进行池化操作,且 pad_value = 0.0 - 输出为 LoDTensor: + 输出为 Tensor: out.shape= [5, 1] out.lod = [[0, 2, 2, 5]] 其中 out.shape[0] == len(x.lod[-1]) == 5 @@ -46,11 +46,11 @@ sequence_last_step 参数 ::::::::: -**input** (Tensor)- 类型为 LoDTensor 的输入序列,仅支持 lod_level 不超过 2 的 LoDTensor,数据类型为 float32。 +**input** (Tensor)- 类型为 Tensor 的输入序列,仅支持 lod_level 不超过 2 的 Tensor,数据类型为 float32。 返回 ::::::::: -每个输入序列中的最后一步特征向量组成的 LoDTensor,数据类型为 float32。 +每个输入序列中的最后一步特征向量组成的 Tensor,数据类型为 float32。 代码示例 ::::::::: diff --git a/docs/api/paddle/static/nn/sequence_pad_cn.rst b/docs/api/paddle/static/nn/sequence_pad_cn.rst index 1226f122907..3f72cff7517 100644 --- a/docs/api/paddle/static/nn/sequence_pad_cn.rst +++ b/docs/api/paddle/static/nn/sequence_pad_cn.rst @@ -9,14 +9,14 @@ sequence_pad 序列填充操作符(Sequence Pad Operator),该 OP 将同一 batch 中的序列填充到一个一致的长度(由 ``maxlen`` 指定)。填充的新元素的值具体由输入 ``pad_value`` 指定,并会添加到每一个序列的末尾,使得他们最终的长度保持一致。最后返回一个 Python tuple ``(Out, Length)``,其中 LodTensor ``Out`` 为填充后的序列,LodTensor ``Length`` 为填充前的原序列长度信息。 .. note:: -该 API 的输入 ``x`` 只能是 LodTensor。 +该 API 的输入 ``x`` 只能是带有 LoD 信息的 Tensor。 范例如下: :: 例 1: - 给定输入 1-level LoDTensor x: + 给定输入 1-level Tensor x: x.lod = [[0, 2, 5]] #输入的两个序列长度是 2 和 3 x.data = [[a],[b],[c],[d],[e]] 和输入 pad_value: @@ -30,7 +30,7 @@ sequence_pad :: 例 2: - 给定输入 1-level LoDTensor x: + 给定输入 1-level Tensor x: x.lod = [[0, 2, 5]] x.data = [[a1,a2],[b1,b2],[c1,c2],[d1,d2],[e1,e2]] 和输入 pad_value: @@ -44,7 +44,7 @@ sequence_pad :: 例 3: - 给定输入 1-level LoDTensor x: + 给定输入 1-level Tensor x: x.lod = [[0, 2, 5]] x.data = [[a1,a2],[b1,b2],[c1,c2],[d1,d2],[e1,e2]] 和输入 pad_value: @@ -59,14 +59,14 @@ sequence_pad 参数 ::::::::: - - **x** (Tensor) - 输入,维度为 ``[M, K]`` 的 LoDTensor,仅支持 lod_level 为 1。lod 所描述的序列数量,作为要填充的 batch_size。数据类型为 int32,int64,float32 或 float64。 + - **x** (Tensor) - 输入,维度为 ``[M, K]`` 的 Tensor,仅支持 lod_level 为 1。lod 所描述的序列数量,作为要填充的 batch_size。数据类型为 int32,int64,float32 或 float64。 - **pad_value** (Tensor) - 填充值,可以是标量或长度为 ``K`` 的一维 Tensor。如果是标量,则自动广播为 Tensor。数据类型需与 ``x`` 相同。 - **maxlen** (int,可选) - 填充序列的长度。默认为 None,此时以序列中最长序列的长度为准,其他所有序列填充至该长度。当是某个特定的正整数,最大长度必须大于最长初始序列的长度。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: -元素为两个 LoDTensor 的 Python tuple。第一个元素为填充后的变量 ``Out``,形状为 ``[batch_size, maxlen, K]`` ,lod level 为 0 的 LoDTensor,数据类型与输入 ``x`` 相同。第二个元素为填充前的原序列长度信息 ``Length`` ,lod level 为 0 的一维 LoDTensor,长度等于 batch_size,数据类型为 int64。 +元素为两个 Tensor 的 Python tuple。第一个元素为填充后的变量 ``Out``,形状为 ``[batch_size, maxlen, K]`` ,lod level 为 0 的 Tensor,数据类型与输入 ``x`` 相同。第二个元素为填充前的原序列长度信息 ``Length`` ,lod level 为 0 的一维 Tensor,长度等于 batch_size,数据类型为 int64。 代码示例 diff --git a/docs/api/paddle/static/nn/sequence_pool_cn.rst b/docs/api/paddle/static/nn/sequence_pool_cn.rst index a5a6965ad46..86f81abbe1c 100644 --- a/docs/api/paddle/static/nn/sequence_pool_cn.rst +++ b/docs/api/paddle/static/nn/sequence_pool_cn.rst @@ -9,9 +9,9 @@ sequence_pool .. note:: -该 API 的输入只能是 LoDTensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.nn.functional.avg_pool2d ` 或 :ref:`paddle.nn.functional.max_pool2d ` 。 +该 API 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.nn.functional.avg_pool2d ` 或 :ref:`paddle.nn.functional.max_pool2d ` 。 -对输入的 LoDTensor 进行指定方式的池化(pooling)操作。通过指定 pool_type 参数,将输入的每个序列(sequence)在最后一层 lod_level 上或时间步(time-step)上对特征进行诸如 sum、average、sqrt 等池化操作。 +对输入的 Tensor 进行指定方式的池化(pooling)操作。通过指定 pool_type 参数,将输入的每个序列(sequence)在最后一层 lod_level 上或时间步(time-step)上对特征进行诸如 sum、average、sqrt 等池化操作。 支持六种 pool_type: @@ -28,11 +28,11 @@ sequence_pool Case 1: - input 是 1-level 的 LoDTensor,且 pad_value = 0.0: + input 是 1-level 的 Tensor,且 pad_value = 0.0: input.lod = [[0, 2, 5, 7, 7]] input.data = [[1.], [3.], [2.], [4.], [6.], [5.], [1.]] input.shape = [7, 1] - 输出为 LoDTensor: + 输出为 Tensor: out.shape = [4, 1] 其中 out.shape[0] == len(x.lod[-1]) == 4 对于不同的 pool_type: @@ -47,7 +47,7 @@ sequence_pool Case 2: - input 是 2-level 的 LoDTensor,包含 3 个长度分别为[2, 0, 3]的序列,其中中间的 0 表示序列为空。 + input 是 2-level 的 Tensor,包含 3 个长度分别为[2, 0, 3]的序列,其中中间的 0 表示序列为空。 第一个长度为 2 的序列包含 2 个长度分别为[1, 2]的子序列; 最后一个长度为 3 的序列包含 3 个长度分别为[1, 0, 3]的子序列。 input.lod = [[0, 2, 2, 5], [0, 1, 3, 4, 4, 7]] @@ -55,7 +55,7 @@ sequence_pool input.shape = [7, 1] 以 pool_type 取值为 sum 为例,将根据最后一层的 lod 信息[0, 1, 3, 4, 4, 7]进行池化操作,且 pad_value = 0.0 - 输出为 LoDTensor: + 输出为 Tensor: out.shape= [5, 1] out.lod = [[0, 2, 2, 5]] 其中 out.shape[0] == len(x.lod[-1]) == 5 @@ -65,14 +65,14 @@ sequence_pool 参数 ::::::::: - - **input** (Tensor) - 类型为 LoDTensor 的输入序列,仅支持 lod_level 不超过 2 的 LoDTensor,数据类型为 float32。 + - **input** (Tensor) - 类型为 Tensor 的输入序列,仅支持 lod_level 不超过 2 的 Tensor,数据类型为 float32。 - **pool_type** (str) - 池化类型,支持 average,sum,sqrt,max,last 和 first 池化操作。 - **is_test** (bool,可选) - 仅在 pool_type 取值为 max 时生效。当 is_test 为 False 时,则在池化操作过程中会创建 maxIndex 临时 Tenosr,以记录最大特征值对应的索引信息,用于训练阶段的反向梯度计算。默认为 False。 - **pad_value** (float,可选) - 用于填充输入序列为空时的池化结果,默认为 0.0。 返回 ::::::::: -经过指定类型池化后的 LoDTensor,数据类型为 float32。 +经过指定类型池化后的 Tensor,数据类型为 float32。 代码示例 ::::::::: diff --git a/docs/api/paddle/static/nn/sequence_reshape_cn.rst b/docs/api/paddle/static/nn/sequence_reshape_cn.rst index 263cdd03281..8e084714d3f 100644 --- a/docs/api/paddle/static/nn/sequence_reshape_cn.rst +++ b/docs/api/paddle/static/nn/sequence_reshape_cn.rst @@ -8,20 +8,20 @@ sequence_reshape .. note:: -该 API 的输入只能是 LoDTensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.reshape ` 。 +该 API 的输入只能是带有 LoD 信息的 Tensor,如果您需要处理的输入是 Tensor 类型,请使用 :ref:`paddle.reshape ` 。 -在指定 ``new_dim`` 参数下,通过序列原始长度、和原始 shape 计算出新的 shape,以输出包含新维度(new_dim)下的 LoDTensor。目前仅支持 1-level LoDTensor,请确保(原长度*原维数)可以除以新的维数,且每个序列没有余数。 +在指定 ``new_dim`` 参数下,通过序列原始长度、和原始 shape 计算出新的 shape,以输出包含新维度(new_dim)下的 Tensor。目前仅支持 1-level Tensor,请确保(原长度*原维数)可以除以新的维数,且每个序列没有余数。 :: - input 是一个 LoDTensor: + 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 - 输出为 LoDTensor: + 输出为 Tensor: out.lod = [[0, 1, 3]] out.data = [[1, 2, 3, 4], @@ -34,12 +34,12 @@ sequence_reshape 参数 ::::::::: - - **input** (Tensor) - 维度为 :math:`[M, K]` 的二维 LoDTensor,且仅支持 lod_level 为 1。数据类型为 int32,int64,float32 或 float64。 - - **new_dim** (int)- 指定 reshape 后的新维度,即对输入 LoDTensor 重新 reshape 后的新维度。 + - **input** (Tensor) - 维度为 :math:`[M, K]` 的二维 Tensor,且仅支持 lod_level 为 1。数据类型为 int32,int64,float32 或 float64。 + - **new_dim** (int)- 指定 reshape 后的新维度,即对输入 Tensor 重新 reshape 后的新维度。 返回 ::::::::: -根据新维度重新 reshape 后的 LoDTensor,数据类型和输入一致。 +根据新维度重新 reshape 后的 Tensor,数据类型和输入一致。 代码示例 diff --git a/docs/api/paddle/static/nn/sequence_reverse_cn.rst b/docs/api/paddle/static/nn/sequence_reverse_cn.rst index 2d86c18decd..69f05a7bd92 100644 --- a/docs/api/paddle/static/nn/sequence_reverse_cn.rst +++ b/docs/api/paddle/static/nn/sequence_reverse_cn.rst @@ -7,13 +7,13 @@ sequence_reverse .. note:: -该 API 仅支持 LoDTensor。 +该 API 仅支持带有 LoD 信息的 Tensor。 -输入的 LoDTensor,在每个序列(sequence)上进行反转。目前仅支持对 LoD 层次(LoD level)为 1 的 LoDTensor 进行反转。该 OP 在构建反向 :ref:`cn_api_fluid_layers_DynamicRNN` 网络时十分有用。 +输入的 Tensor,在每个序列(sequence)上进行反转。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。该 OP 在构建反向 :ref:`cn_api_fluid_layers_DynamicRNN` 网络时十分有用。 :: - 输入 x 是一个 LoDTensor: + 输入 x 是一个 Tensor: x.lod = [[0, 2, 5]] x.data = [[1, 2, 3, 4], [5, 6, 7, 8], @@ -35,12 +35,12 @@ sequence_reverse 参数 ::::::::: - - **x** (Variable) – 输入是 LoD level 为 1 的 LoDTensor。目前仅支持对 LoD 层次(LoD level)为 1 的 LoDTensor 进行反转。数据类型为 float32,float64,int8,int32 或 int64。 + - **x** (Variable) – 输入是 LoD level 为 1 的 Tensor。目前仅支持对 LoD 层次(LoD level)为 1 的 Tensor 进行反转。数据类型为 float32,float64,int8,int32 或 int64。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: -输出在每个序列上反转后的 LoDTensor,数据类型和输入类型一致。 +输出在每个序列上反转后的 Tensor,数据类型和输入类型一致。 代码示例 :::::::::::: diff --git a/docs/api/paddle/static/nn/sequence_scatter_cn.rst b/docs/api/paddle/static/nn/sequence_scatter_cn.rst index 03eac0993c9..f414006ee6d 100644 --- a/docs/api/paddle/static/nn/sequence_scatter_cn.rst +++ b/docs/api/paddle/static/nn/sequence_scatter_cn.rst @@ -8,7 +8,7 @@ sequence_scatter .. note:: - 该 OP 的输入 index,updates 必须是 LoDTensor。 + 该 OP 的输入 index,updates 必须是带有 LoD 信息的 Tensor。 根据 index 提供的位置将 updates 中的信息更新到输出中。 @@ -46,8 +46,8 @@ output[i][j]的值取决于能否在 index 中第 i+1 个区间中找到对应 参数 ::::::::: - **input** (Tensor) - 维度为 :math:`[N, k_1 ... k_n]` 的 Tensor,支持的数据类型:float32,float64,int32,int64。 - - **index** (Tensor) - 包含 index 信息的 LoDTensor,lod level 必须等于 1,支持的数据类型:int32,int64。 - - **updates** (Tensor) - 包含 updates 信息的 LoDTensor,lod level 和 index 一致,数据类型与 input 的数据类型一致。支持的数据类型:float32,float64,int32,int64。 + - **index** (Tensor) - 包含 index 信息的 Tensor,lod level 必须等于 1,支持的数据类型:int32,int64。 + - **updates** (Tensor) - 包含 updates 信息的 Tensor,lod level 和 index 一致,数据类型与 input 的数据类型一致。支持的数据类型:float32,float64,int32,int64。 - **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 diff --git a/docs/api/paddle/static/nn/sequence_slice_cn.rst b/docs/api/paddle/static/nn/sequence_slice_cn.rst index e2abfbb04b7..f5f27468ad9 100644 --- a/docs/api/paddle/static/nn/sequence_slice_cn.rst +++ b/docs/api/paddle/static/nn/sequence_slice_cn.rst @@ -10,7 +10,8 @@ sequence_slice 从给定序列中截取子序列。截取依据为按照所给相对开始位置的 ``offset`` (偏移量)和子序列长度 ``length`` 来截取子序列。 -该 API 输入只能是 LoDTensor,如果您需要处理的是 Tensor 类型,请使用 :ref:`paddle.slice ` 。 +.. note:: +该 API 输入只能是带有 LoD 信息的 Tensor,如果您需要处理的是 Tensor 类型,请使用 :ref:`paddle.slice ` 。 .. code-block:: text @@ -21,9 +22,9 @@ sequence_slice input.dims = [5, 2] offset.data = [[0], [1]] - length.data = [[2], [1]] + 输出: out.data = [[a1, a2], [b1, b2], [e1, e2]], @@ -37,7 +38,7 @@ sequence_slice 参数 ::::::::: - - **input** (Tensor) – 输入变量,类型为 LoDTensor,承载着完整的序列。数据类型为 float32,float64,int32 或 int64。 + - **input** (Tensor) – 输入变量,类型为 Tensor,承载着完整的序列。数据类型为 float32,float64,int32 或 int64。 - **offset** (Tensor) – 指定每个序列切片的起始索引,数据类型为 int32 或 int64。 - **length** (Tensor) – 指定每个子序列的长度,数据类型为 int32 或 int64。 - **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 diff --git a/docs/api/paddle/static/nn/sequence_softmax_cn.rst b/docs/api/paddle/static/nn/sequence_softmax_cn.rst index 162483146c2..ea937441e3a 100644 --- a/docs/api/paddle/static/nn/sequence_softmax_cn.rst +++ b/docs/api/paddle/static/nn/sequence_softmax_cn.rst @@ -7,7 +7,7 @@ sequence_softmax .. py:function:: paddle.static.nn.sequence_softmax(input, use_cudnn=False, name=None) .. note:: - 该 API 的输入只能是 LoDTensor,如果要处理的输入是 Tensor 类型,请使用 :ref:`paddle.nn.functional.softmax `。 + 该 API 的输入只能是带有 LoD 信息的 Tensor,如果要处理的输入是 Tensor 类型,请使用 :ref:`paddle.nn.functional.softmax `。 根据 LoD 信息将输入的第 0 维度进行划分,在划分的每一个区间内部进行运算。 @@ -46,13 +46,13 @@ sequence_softmax 参数 ::::::::: - - **input** (Tensor) - 维度为 :math:`[N, 1]` 或者 :math:`[N]` 的 LoDTensor,推荐使用 :math:`[N]`。支持的数据类型:float32,float64。 + - **input** (Tensor) - 维度为 :math:`[N, 1]` 或者 :math:`[N]` 的 Tensor,推荐使用 :math:`[N]`。支持的数据类型:float32,float64。 - **use_cudnn** (bool,可选) - 是否用 cudnn 核,仅当安装 cudnn 版本的 paddle 库且使用 gpu 训练或推理的时候生效。支持的数据类型:bool 型。默认值为 False。 - **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 ::::::::: -根据区间计算 softmax 之后的 LoDTensor,其维度与 input 的维度一致,数据类型与 input 的数据类型一致。 +根据区间计算 softmax 之后的 Tensor,其维度与 input 的维度一致,数据类型与 input 的数据类型一致。 代码示例 diff --git a/docs/api/paddle/static/nn/sequence_unpad_cn.rst b/docs/api/paddle/static/nn/sequence_unpad_cn.rst index 48e3b311fab..487ca0a659c 100644 --- a/docs/api/paddle/static/nn/sequence_unpad_cn.rst +++ b/docs/api/paddle/static/nn/sequence_unpad_cn.rst @@ -9,9 +9,9 @@ sequence_unpad .. note:: - 该 API 的输入为 Tensor,输出为 LoDTensor。用于移除填充元素,与之对应,还存在进行数据填充的 API :ref:`cn_api_fluid_layers_sequence_pad`。 + 该 API 的输入为 Tensor,输出为带有 LoD 信息的 Tensor。用于移除填充元素,与之对应,还存在进行数据填充的 API :ref:`cn_api_fluid_layers_sequence_pad`。 -根据 length 的信息,将 input 中 padding(填充)元素移除,并且返回一个 LoDTensor。 +根据 length 的信息,将 input 中 padding(填充)元素移除,并且返回一个带有 LoD 信息的 Tensor。 :: @@ -41,7 +41,7 @@ sequence_unpad 返回 ::::::::: -将输入的填充元素移除,并返回一个 LoDTensor,其递归序列长度与 length 参数的信息一致,其数据类型和输入一致。 +将输入的填充元素移除,并返回一个带有 LoD 信息的 Tensor,其递归序列长度与 length 参数的信息一致,其数据类型和输入一致。 代码示例 ::::::::: diff --git a/docs/api/paddle/static/nn/sparse_embedding_cn.rst b/docs/api/paddle/static/nn/sparse_embedding_cn.rst index 0aa30c975e8..702a82170e0 100644 --- a/docs/api/paddle/static/nn/sparse_embedding_cn.rst +++ b/docs/api/paddle/static/nn/sparse_embedding_cn.rst @@ -39,14 +39,14 @@ input 中的 id 必须满足 ``0 =< id < size[0]``,否则程序会抛异常退 Case 2: - input 是 lod level 为 1 的 LoDTensor,且 padding_idx = 0 + input 是 lod level 为 1 的 Tensor,且 padding_idx = 0 input.lod = [[2, 3]] input.data = [[1], [3], [2], [4], [0]] input.shape = [5, 1] 若 size = [128, 16] - 输出为 LoDTensor: + 输出为 Tensor: out.lod = [[2, 3]] out.shape = [5, 1, 16] out.data = [[[0.129435295, 0.244512452, ..., 0.436322452]], diff --git a/docs/api/paddle/vision/ops/distribute_fpn_proposals_cn.rst b/docs/api/paddle/vision/ops/distribute_fpn_proposals_cn.rst index 515c35e90d1..7cfc77c6469 100644 --- a/docs/api/paddle/vision/ops/distribute_fpn_proposals_cn.rst +++ b/docs/api/paddle/vision/ops/distribute_fpn_proposals_cn.rst @@ -31,7 +31,7 @@ distribute_fpn_proposals 返回 :::::::::::: -- **multi_rois** (List) - 长度为(max_level-min_level+1)的列表,其中元素为 Variable,维度为[M, 4]的 2-D LoDTensor,M 为每个级别 proposal 的个数,数据类型为 float32 或 float64。表示每个 FPN 级别包含的 proposals。 +- **multi_rois** (List) - 长度为(max_level-min_level+1)的列表,其中元素为 Variable,维度为[M, 4]的 2-D Tensor,M 为每个级别 proposal 的个数,数据类型为 float32 或 float64。表示每个 FPN 级别包含的 proposals。 - **restore_ind** (Tensor) - 维度为[N,1]的 Tensor,N 是总 rois 的数量。数据类型为 int32。它用于恢复 fpn_rois 的顺序。 - **rois_num_per_level** (List) - 一个包含 1-D Tensor 的 List。其中每个元素是每张图在对应层级上的 RoI 数量。数据类型为 int32。