mindspore.ops.dstack

查看源文件
mindspore.ops.dstack(tensors)[源代码]

将多个tensor沿着第三维度进行堆叠。

说明

  • 一维tensor (N,) 重新排列为 (1,N,1) ,二维tensor (M,N) 重新排列为 (M,N,1)

  • 除了第三个轴外,所有的tensor必须有相同的shape。如果是1-D或2-D的tensor,则它们的shape必须相同。

参数:
  • tensors (Union(List[Tensor], Tuple[Tensor])) - 由多个tensor组成的list或tuple。

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> import numpy as np
>>> x1 = mindspore.tensor(np.arange(1, 7).reshape(2, 3))
>>> x2 = mindspore.tensor(np.arange(7, 13).reshape(2, 3))
>>> out = mindspore.ops.dstack([x1, x2])
>>> print(out.asnumpy())
[[[ 1.  7.]
  [ 2.  8.]
  [ 3.  9.]]
 [[ 4. 10.]
  [ 5. 11.]
  [ 6. 12.]]]