- paddle.static.nn. sequence_reshape ( input, new_dim ) [source]
Only receives LoDTensor as input. If your input is Tensor, please use reshape Op.(fluid.layers.** api_fluid_layers_reshape ).
Only supports LoDTensor as input. Given
new_dim, it will compute new shape according to original length of each sequence, original dimensions and
new_dim. Then it will output a new LoDTensor containing
new_dim. Currently it only supports 1-level LoDTensor. Please make sure that (original length * original dimensions) can be divided by the
new_dimwith no remainder for each sequence.
input is a LoDTensor: input.lod = [[0, 2, 6]] input.data = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]] input.shape = [6, 2] set new_dim = 4 out is a LoDTensor: out.lod = [[0, 1, 3]] out.data = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] out.shape = [3, 4]
input (Variable) – 1-level LoDTensor with shape \([M, K]\) . The data type should be int32, int64, float32 or float64.
new_dim (int) – New dimension that the input LoDTensor is reshaped to.
Reshaped LoDTensor according to new dimension. The data type is same as input.
- Return type
import paddle paddle.enable_static() x = paddle.static.data(name='x', shape=[None, 16], dtype='float32', lod_level=1) x_reshaped = paddle.static.nn.sequence_reshape(input=x, new_dim=4)