Warning
This page was created from a pull request.
jax.numpy.broadcast_to¶
-
jax.numpy.
broadcast_to
(arr, shape)[source]¶ Broadcast an array to a new shape.
LAX-backend implementation of
broadcast_to()
. The JAX version does not necessarily return a view of the input.Original docstring below.
- Parameters
shape (tuple) – The shape of the desired array.
- Returns
broadcast – A readonly view on the original array with the given shape. It is typically not contiguous. Furthermore, more than one element of a broadcasted array may refer to a single memory location.
- Return type
array
- Raises
ValueError – If the array is not compatible with the new shape according to NumPy’s broadcasting rules.
Notes
New in version 1.10.0.
Examples
>>> x = np.array([1, 2, 3]) >>> np.broadcast_to(x, (3, 3)) array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])