chainer.functions.tile¶
-
chainer.functions.
tile
(x, reps)[source]¶ Construct an array by tiling a given array.
Parameters: - x (
Variable
ornumpy.ndarray
orcupy.ndarray
) – Input variable. Let the length ofreps
bed
. Ifx.ndim < d
,x
is treated asd
-dimensional array by prepending new axes. For example, when the shape ofx
is(2,)
and tiled with 2-dim repetitions,x
is treated as the shape(1, 2)
. Ifx.ndim > d
,reps
is treated asx.ndim
-dimensional by pre-pending 1’s. For example, when the shape ofx
is(2, 3, 2, 3)
, the 2-dimreps
of(2, 2)
is treated as(1, 1, 2, 2)
. - reps (
int
ortuple
ofint
s) – The number of times whichx
is replicated along each axis.
Returns: The tiled output Variable. Let the length of
reps
bed
, the output has the dimension ofmax(d, x.ndim)
.Return type: Example
>>> x = np.array([0, 1, 2]) >>> x.shape (3,) >>> y = np.tile(x, 2) >>> y.shape (6,) >>> y array([0, 1, 2, 0, 1, 2]) >>> y = np.tile(x, (2, 2)) >>> y.shape (2, 6) >>> y array([[0, 1, 2, 0, 1, 2], [0, 1, 2, 0, 1, 2]]) >>> y = np.tile(x, (2, 1, 2)) >>> y.shape (2, 1, 6) >>> y array([[[0, 1, 2, 0, 1, 2]], [[0, 1, 2, 0, 1, 2]]])
>>> x = np.array([[1, 2], [3, 4]]) >>> x.shape (2, 2) >>> y = np.tile(x, 2) >>> y.shape (2, 4) >>> y array([[1, 2, 1, 2], [3, 4, 3, 4]]) >>> y = np.tile(x, (2, 2)) >>> y.shape (4, 4) >>> y array([[1, 2, 1, 2], [3, 4, 3, 4], [1, 2, 1, 2], [3, 4, 3, 4]]) >>> y = np.tile(x, (2, 1, 2)) >>> y.shape (2, 2, 4) >>> y array([[[1, 2, 1, 2], [3, 4, 3, 4]], [[1, 2, 1, 2], [3, 4, 3, 4]]])
- x (