mindspore.ops.vstack

View Source On Gitee
mindspore.ops.vstack(inputs)[source]

Stacks tensors in sequence vertically.

This is equivalent to concatenation along the first axis. 1-D tensors (N,) should firstly be reshaped to (1,N), and then be concatenated along the first axis.

Parameters

inputs (Union(List[tensor], Tuple[tensor])) – The 1-D or 2-D input.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> x1 = mindspore.tensor([1, 2, 3])
>>> x2 = mindspore.tensor([4, 5, 6])
>>> mindspore.ops.vstack((x1, x2))
Tensor(shape=[2, 3], dtype=Int64, value=
[[1, 2, 3],
 [4, 5, 6]])
>>> x1 = mindspore.tensor([[1],[2],[3]])
>>> x2 = mindspore.tensor([[4],[5],[6]])
>>> mindspore.ops.vstack([x1, x2])
Tensor(shape=[6, 1], dtype=Int64, value=
[[1],
 [2],
 [3],
 [4],
 [5],
 [6]])