mindspore.ops.vstack

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])) – A sequence of 1-D or 2-D tensors. The tensors must have the same shape along all but the first axis. 1-D tensors must have the same shape.

Returns

Tensor, formed by stacking the given tensors, will be at least 3-D. The output shape is similar to the output of numpy.vstack() function.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> x1 = np.array([3, 1, 4])
>>> x2 = np.array([1, 5, 9])
>>> out = ops.vstack([x1, x2])
>>> print(out)
[[3 1 4]
 [1 5 9]]