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
  • input (Tensor) – The shape is \((n_1, n_2, ..., n_R)\). A tensor to be unstacked and the rank of the tensor must be greater than 0.

  • dim (int) – Dimension along which to unpack. Negative values wrap around. The range is [-R, R). Default: 0.

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

>>> 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]))