mindspore.mint.unbind

mindspore.mint.unbind(input, dim=0)[source]

Unbind a tensor dimension in specified axis.

Given a 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.

Warning

This is an experimental API that is subject to change or deletion.

Parameters
  • input (Tensor) – The input tensor to unbind, with a shape of \((n_1, n_2, ..., n_R)\). The rank of the tensor must be greater than 0.

  • 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
Supported Platforms:

Ascend

Examples

>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> input = Tensor(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]))
>>> output = mint.unbind(input, 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]))