sequence_concat

注意:该API仅支持【静态图】模式

  • paddle.fluid.layers.sequence_concat(input, name=None)[源代码]

注意:该OP的输入只能是LoDTensor,如果您需要处理的输入是Tensor类型,请使用concat函数(fluid.layers. concat )。

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

  1. input是由多个LoDTensor组成的list
  2. input = [x1, x2]
  3. 其中:
  4. x1.lod = [[0, 3, 5]]
  5. x1.data = [[1], [2], [3], [4], [5]]
  6. x1.shape = [5, 1]
  7.  
  8. x2.lod = [[0, 2, 4]]
  9. x2.data = [[6], [7], [8], [9]]
  10. x2.shape = [4, 1]
  11. 且必须满足:len(x1.lod[0]) == len(x2.lod[0])
  12.  
  13. 输出为LoDTensor
  14. out.lod = [[0, 3+2, 5+4]]
  15. out.data = [[1], [2], [3], [6], [7], [4], [5], [8], [9]]
  16. out.shape = [9, 1]
  • 参数:
    • input (list of Variable) – 多个LoDTensor组成的list,要求每个输入LoDTensor的LoD长度必须一致。数据类型为float32,float64或int64。
    • name (str,可选) – 具体用法请参见 Name ,一般无需设置,默认值为None。

返回: 输出连接后的LoDTensor,数据类型和输入一致。

返回类型: Variable

代码示例

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