unbind¶
- paddle. unbind ( input, axis=0 ) [source]
-
Removes a tensor dimension, then split the input tensor into multiple sub-Tensors.
- Parameters
-
input (Tensor) – The input variable which is an N-D Tensor, data type being bool, float16, float32, float64, int32 or int64.
axis (int32|int64, optional) – A scalar with type
int32|int64
shape [1]. The dimension along which to unbind. If \(axis < 0\), the dimension to unbind along is \(rank(input) + axis\). Default is 0.
- Returns
-
list(Tensor), The list of segmented Tensor variables.
Example
import paddle # input is a Tensor which shape is [3, 4, 5] input = paddle.rand([3, 4, 5]) [x0, x1, x2] = paddle.unbind(input, axis=0) # x0.shape [4, 5] # x1.shape [4, 5] # x2.shape [4, 5] [x0, x1, x2, x3] = paddle.unbind(input, axis=1) # x0.shape [3, 5] # x1.shape [3, 5] # x2.shape [3, 5] # x3.shape [3, 5]