mindspore.numpy.dstack
- mindspore.numpy.dstack(tup)[源代码]
- Stacks tensors in sequence depth wise (along the third axis). This is equivalent to concatenation along the third axis. 1-D tensors \((N,)\) should be reshaped to \((1,N,1)\). 2-D tensors \((M,N)\) should be reshaped to \((M,N,1)\) before concatenation. - 参数
- tup (Union[Tensor, tuple, list]) – A sequence of tensors. The tensors must have the same shape along all but the third axis. 1-D or 2-D tensors must have the same shape. 
- 返回
- Stacked Tensor, formed by stacking the given tensors. 
 - Supported Platforms:
- Ascend- GPU- CPU
 - 异常
- TypeError – If tup is not Tensor, list or tuple. 
- ValueError – If tup is empty. 
 
 - 样例 - >>> import mindspore.numpy as np >>> x1 = np.array([1, 2, 3]).astype('float32') >>> x2 = np.array([4, 5, 6]).astype('float32') >>> output = np.dstack((x1, x2)) >>> print(output) [[[1. 4.] [2. 5.] [3. 6.]]]