dsplit

paddle. dsplit ( x: Tensor, num_or_indices: int | Sequence[int], name: str | None = None ) list[Tensor] [source]

dsplit Full name Depth Split, splits the input Tensor into multiple sub-Tensors along the depth axis, which is equivalent to paddle.tensor_split with axis=2.

Note

Make sure that the number of Tensor dimensions transformed using paddle.dsplit must be no less than 3.

In the following figure, Tenser x has shape [4, 4, 4], and after paddle.dsplit(x, num_or_indices=2) transformation, we get out0 and out1 sub-Tensors whose shapes are both [4, 4, 2] :

https://githubraw.cdn.bcebos.com/PaddlePaddle/docs/develop/docs/images/api_legend/dsplit/dsplit.png
Parameters
  • x (Tensor) – A Tensor whose dimension must be greater than 2. The data type is bool, bfloat16, float16, float32, float64, uint8, int32 or int64.

  • num_or_indices (int|list|tuple) – If num_or_indices is an int n, x is split into n sections. If num_or_indices is a list or tuple of integer indices, x is split at each of the indices.

  • name (str|None, 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.

Examples

>>> import paddle

>>> # x is a Tensor of shape [7, 6, 8]
>>> x = paddle.rand([7, 6, 8])
>>> out0, out1 = paddle.dsplit(x, num_or_indices=2)
>>> print(out0.shape)
[7, 6, 4]
>>> print(out1.shape)
[7, 6, 4]

>>> out0, out1, out2 = paddle.dsplit(x, num_or_indices=[1, 4])
>>> print(out0.shape)
[7, 6, 1]
>>> print(out1.shape)
[7, 6, 3]
>>> print(out2.shape)
[7, 6, 4]