chainer.functions.repeat¶
-
chainer.functions.
repeat
(x, repeats, axis=None)[source]¶ Construct an array by repeating a given array.
Parameters: - x (
Variable
ornumpy.ndarray
orcupy.ndarray
) – Input variable. - repeats (
int
ortuple
ofint
s) – The number of times which each element ofx
is repeated. - axis (
int
) – The axis along which to repeat values.
Returns: The repeated output Variable.
Return type: Example
>>> x = np.array([0, 1, 2]) >>> x.shape (3,) >>> y = F.repeat(x, 2) >>> y.shape (6,) >>> y.data array([0, 0, 1, 1, 2, 2]) >>> x = np.array([[1,2], [3,4]]) >>> x.shape (2, 2) >>> y = F.repeat(x, 3, axis=1) >>> y.shape (2, 6) >>> y.data array([[1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4]]) >>> y = F.repeat(x, (1, 2), axis=0) >>> y.shape (3, 2) >>> y.data array([[1, 2], [3, 4], [3, 4]])
- x (