# chainer.functions.vstack¶

chainer.functions.vstack(xs)[source]

Concatenate variables vertically (row wise).

Parameters: xs (list of Variable or N-dimensional array) – Input variables to be concatenated. The variables must have the same ndim. When the variables have the second axis (i.e. $$ndim \geq 2$$), the variables must have the same shape along all but the first axis. When the variables do not have the second axis(i.e. $$ndim < 2$$), the variables must have the same shape. Output variable. When the input variables have the second axis (i.e. $$ndim \geq 2$$), the shapes of inputs and output are the same along all but the first axis. The length of first axis is the sum of the lengths of inputs’ first axis. When the variables do not have the second axis (i.e. $$ndim < 2$$), the shape of output is (2, N) (N is the size of the input variable). Variable

Example

>>> x1 = np.array((1, 2, 3))
>>> x1.shape
(3,)
>>> x2 = np.array((2, 3, 4))
>>> x2.shape
(3,)
>>> y = F.vstack((x1, x2))
>>> y.shape
(2, 3)
>>> y.data
array([[1, 2, 3],
[2, 3, 4]])
>>> x1 = np.arange(0, 12).reshape(3, 4)
>>> x1.shape
(3, 4)
>>> x1
array([[ 0,  1,  2,  3],
[ 4,  5,  6,  7],
[ 8,  9, 10, 11]])
>>> x2 = np.arange(12, 20).reshape(2, 4)
>>> x2.shape
(2, 4)
>>> x2
array([[12, 13, 14, 15],
[16, 17, 18, 19]])
>>> y = F.vstack([x1, x2])
>>> y.shape
(5, 4)
>>> y.data
array([[ 0,  1,  2,  3],
[ 4,  5,  6,  7],
[ 8,  9, 10, 11],
[12, 13, 14, 15],
[16, 17, 18, 19]])