mindspore.numpy.dstack
- mindspore.numpy.dstack(tup)[source]
Stacks tensors in sequence depth wise (along the third axis). This is equivalent to concatenation along the third axis. 1-D tensors
should be reshaped to . 2-D tensors should be reshaped to before concatenation.- Parameters
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.
- Returns
Stacked Tensor, formed by stacking the given tensors.
- Supported Platforms:
Ascend
GPU
CPU
- Raises
TypeError – If tup is not Tensor, list or tuple.
ValueError – If tup is empty.
Examples
>>> 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.]]]