chainer.functions.separate¶
-
chainer.functions.
separate
(x, axis=0)[source]¶ Separates an array along a given axis.
This function separates an array along a given axis. For example, shape of an array is
(2, 3, 4)
. When it separates the array withaxis=1
, it returns three(2, 4)
arrays.This function is an inverse of
chainer.functions.stack()
.- Parameters
x (
Variable
or N-dimensional array) – Variable to be separated. A \((s_1, s_2, ..., s_N)\) -shaped float array.axis (int) – Axis along which variables are separated.
- Returns
Output variables.
- Return type
tuple of chainer.Variable
See also
Example
>>> x = np.arange(6).reshape((2, 3)).astype(np.float32) >>> x array([[0., 1., 2.], [3., 4., 5.]], dtype=float32) >>> x.shape (2, 3) >>> y = F.separate(x) # split along axis=0 >>> isinstance(y, tuple) True >>> len(y) 2 >>> y[0].shape (3,) >>> y[0].array array([0., 1., 2.], dtype=float32) >>> y = F.separate(x, axis=1) >>> len(y) 3 >>> y[0].shape (2,) >>> y[0].array array([0., 3.], dtype=float32)