chainer.functions.broadcast_to

chainer.functions.broadcast_to(x, shape)[source]

Broadcast a given variable to a given shape.

Parameters:
  • x (Variable or numpy.ndarray or cupy.ndarray) – Input variable be broadcasted. A \((s_1, s_2, ..., s_N)\)-shaped float array.
  • shape (tuple) – Tuple of int of the shape of the output variable.
Returns:

Output variable broadcasted to the given shape.

Return type:

Variable

Example

>>> x = np.arange(0, 3)
>>> x
array([0, 1, 2])
>>> y = F.broadcast_to(x, (3, 3))
>>> y.data
array([[0, 1, 2],
       [0, 1, 2],
       [0, 1, 2]])