mindspore.numpy.column_stack
- mindspore.numpy.column_stack(tup)[源代码]
Stacks 1-D tensors as columns into a 2-D tensor. 2-D tensors are stacked as-is, like np.hstack.
- Parameters
tup (Union[Tensor, tuple, list]) – A sequence of 1-D or 2-D tensors. All of them must have the same shape except the axis to be concatenated.
- Returns
2-D 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('int32') >>> x2 = np.array([4, 5, 6]).astype('int32') >>> output = np.column_stack((x1, x2)) >>> print(output) [[1 4] [2 5] [3 6]]