vsplit

paddle. vsplit ( x, num_or_sections, name=None ) [source]

Split the input tensor into multiple sub-Tensors along the vertical axis, which is equivalent to paddle.split with axis=0.

Parameters
  • x (Tensor) – A Tensor whose dimension must be greater than 1. The data type is bool, float16, float32, float64, uint8, int8, int32 or int64.

  • num_or_sections (int|list|tuple) – If num_or_sections is an int, then num_or_sections indicates the number of equal sized sub-Tensors that the x will be divided into. If num_or_sections is a list or tuple, the length of it indicates the number of sub-Tensors and the elements in it indicate the sizes of sub-Tensors’ dimension orderly. The length of the list must not be larger than the x ‘s size of axis 0.

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name .

Returns

list[Tensor], The list of segmented Tensors.

Example

import paddle

# x is a Tensor of shape [8, 6, 7]
x = paddle.rand([8, 6, 7])
out0, out1 = paddle.vsplit(x, num_or_sections=2)
print(out0.shape)  # [4, 6, 7]
print(out1.shape)  # [4, 6, 7]
out0, out1, out2 = paddle.vsplit(x, num_or_sections=[1, 3, 4])
print(out0.shape)  # [1, 6, 7]
print(out1.shape)  # [3, 6, 7]
print(out2.shape)  # [4, 6, 7]
out0, out1, out2 = paddle.vsplit(x, num_or_sections=[2, 3, -1])
print(out0.shape)  # [2, 6, 7]
print(out1.shape)  # [3, 6, 7]
print(out2.shape)  # [3, 6, 7]