mindspore.ops.unbind
- mindspore.ops.unbind(input, dim=0)[source]
Removes a tensor dimension in specified axis.
Unstacks a tensor of rank R along axis dimension, and output tensors will have rank (R-1).
Given a tensor of shape \((n_1, n_2, ..., n_R)\) and a specified dim, shape of the output tensors is \((n_1, n_2, ..., n_{dim}, n_{dim+2}, ..., n_R)\).
- Parameters
- Returns
A tuple of tensors, the shape of each objects is the same.
- Raises
ValueError – If axis is out of the range [-R, R).
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor, ops >>> x = Tensor(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) >>> output = ops.unbind(x, dim=0) >>> print(output) (Tensor(shape=[3], dtype=Int64, value=[1, 2, 3]), Tensor(shape=[3], dtype=Int64, value=[4, 5, 6]), Tensor(shape=[3], dtype=Int64, value=[7, 8, 9]))