mindspore.ops.Unstack
- class mindspore.ops.Unstack(axis=0, num=None)[source]
Unstacks tensor in specified axis, this is the opposite of ops.Stack. Assuming input is a tensor of rank R, output tensors will have rank (R-1).
Refer to
mindspore.ops.unstack()
for more details.- Parameters
- Inputs:
input_x (Tensor) - The shape is \((x_1, x_2, ..., x_R)\). A tensor to be unstacked and the rank of the tensor must be greater than 0.
- Outputs:
A tuple of tensors, the shape of each objects is the same. Given a tensor of shape \((x_1, x_2, ..., x_R)\). If \(0 \le axis\), the shape of tensor in output is \((x_1, x_2, ..., x_{axis}, x_{axis+2}, ..., x_R)\).
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor, ops >>> unstack = ops.Unstack() >>> input_x = Tensor(np.array([[1, 1, 1, 1], [2, 2, 2, 2]])) >>> output = unstack(input_x) >>> print(output) (Tensor(shape=[4], dtype=Int64, value= [1, 1, 1, 1]), Tensor(shape=[4], dtype=Int64, value= [2, 2, 2, 2]))