mindspore.Tensor.unbind
- Tensor.unbind(dim=0) Tensor
Unbind the tensor dimension in specified axis.
Given self tensor of shape \((n_1, n_2, ..., n_R)\) and unbinding it in the specified dim, multiple tensors with shape \((n_1, n_2, ..., n_{dim}, n_{dim+2}, ..., n_R)\) are returned.
- Parameters
dim (int, optional) – Dimension along which to unbind. The range is [-R, R). Default:
0
.- Returns
A tuple of tensors, the shape of each objects is the same.
- Raises
TypeError – If dim is not an int.
ValueError – If dim is out of the range [-R, R).
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor >>> input = Tensor(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) >>> output = input.unbind(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]))