# sequence_slice¶

API属性：声明式编程(静态图)专用API

`paddle.fluid.layers.` `sequence_slice` ( input, offset, length, name=None ) [源代码]

::

1. input (LoDTensor):
input.data = [[a1, a2], [b1, b2], [c1, c2], [d1, d2], [e1, e2]], input.lod = [[3, 2]], input.dims = (5, 2),
2. offset (Variable):
offset.data = [[0], [1]]
3. length (Variable):
length.data = [[2], [1]]
4. name (str|None)

out.data = [[a1, a2], [b1, b2], [e1, e2]], out.lod = [[2, 1]], out.dims = (3, 2).

## 参数¶

• input (Variable) – 输入变量，类型为LoDTensor，承载着完整的序列
• offset (Variable) – 指定每个序列切片的起始索引，数据类型为int32或int64。
• length (Variable) – 指定每个子序列的长度，数据类型为int32或int64。
• name (str，可选) – 具体用法请参见 Name ，一般无需设置，默认值为None。

## 返回¶

Variable(LoDTensor) 序列切片运算结果

## 代码示例¶

```import paddle.fluid as fluid
import numpy as np
seqs = fluid.layers.data(name='x', shape=[10, 5],
dtype='float32', lod_level=1)
offset = fluid.layers.assign(input=np.array([[0, 1]]).astype("int32"))
length = fluid.layers.assign(input=np.array([[2, 1]]).astype("int32"))
subseqs = fluid.layers.sequence_slice(input=seqs, offset=offset,
length=length)
```