mindspore.ops.unbind

mindspore.ops.unbind(x, dim=0)[源代码]

根据指定轴对输入矩阵进行分解。

若输入Tensor在指定的轴上的rank为 R ,则输出Tensor的rank为 (R-1)

给定一个shape为 \((x_1, x_2, ..., x_R)\) 的Tensor。如果存在 \(0 \le axis\) ,则输出Tensor的shape为 \((x_1, x_2, ..., x_{axis}, x_{axis+2}, ..., x_R)\)

参数:
  • x (Tensor) - 输入Tensor,其shape为 \((x_1, x_2, ..., x_R)\) 。rank必须大于0。

  • dim (int) - 指定矩阵分解的轴。取值范围为[-R, R),默认值:0。

返回:

Tensor对象组成的tuple。每个Tensor对象的shape相同。

异常:
  • ValueError - dim 超出[-R, R)范围。

支持平台:

Ascend GPU CPU

样例:

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