sequence_concat_cn.rst 1.7 KB
Newer Older
H
Hao Wang 已提交
1 2 3 4 5
.. _cn_api_fluid_layers_sequence_concat:

sequence_concat
-------------------------------

L
liuwei1031 已提交
6
:api_attr: 声明式编程模式(静态图)
7

H
Hao Wang 已提交
8 9
.. py:function:: paddle.fluid.layers.sequence_concat(input, name=None)

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
**注意:该OP的输入只能是LoDTensor,如果您需要处理的输入是Tensor类型,请使用concat函数(fluid.layers.** :ref:`cn_api_fluid_layers_concat` **)。**

**该OP仅支持LoDTensor** ,通过LoDTensor的LoD信息将输入的多个LoDTensor进行连接(concat),输出连接后的LoDTensor。

::

    input是由多个LoDTensor组成的list:
        input = [x1, x2]
    其中:
        x1.lod = [[0, 3, 5]]
        x1.data = [[1], [2], [3], [4], [5]]
        x1.shape = [5, 1]

        x2.lod = [[0, 2, 4]]
        x2.data = [[6], [7], [8], [9]]
        x2.shape = [4, 1]
    且必须满足:len(x1.lod[0]) == len(x2.lod[0])
    
    输出为LoDTensor:
        out.lod = [[0, 3+2, 5+4]]
        out.data = [[1], [2], [3], [6], [7], [4], [5], [8], [9]]
        out.shape = [9, 1]

H
Hao Wang 已提交
33 34

参数:
35
        - **input** (list of Variable) – 多个LoDTensor组成的list,要求每个输入LoDTensor的LoD长度必须一致。数据类型为float32,float64或int64。
36
        - **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。
H
Hao Wang 已提交
37

38
返回: 输出连接后的LoDTensor,数据类型和输入一致。
H
Hao Wang 已提交
39

40
返回类型: Variable
H
Hao Wang 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60


**代码示例**

..  code-block:: python

        import paddle.fluid as fluid
        x = fluid.layers.data(name='x', shape=[10], dtype='float32')
        y = fluid.layers.data(name='y', shape=[10], dtype='float32')
        out = fluid.layers.sequence_concat(input=[x, y])