jax.numpy.full#
- jax.numpy.full(shape, fill_value, dtype=None, *, device=None)[source]#
Create an array full of a specified value.
JAX implementation of
numpy.full()
.- Parameters:
shape (Any) – int or sequence of ints specifying the shape of the created array.
fill_value (Array | ndarray | bool | number | bool | int | float | complex) – scalar or array with which to fill the created array.
dtype (str | type[Any] | dtype | SupportsDType | None) – optional dtype for the created array; defaults to the dtype of the fill value.
device (Device | Sharding | None) – (optional)
Device
orSharding
to which the created array will be committed.
- Returns:
Array of the specified shape and dtype, on the specified device if specified.
- Return type:
Examples
>>> jnp.full(4, 2, dtype=float) Array([2., 2., 2., 2.], dtype=float32) >>> jnp.full((2, 3), 0, dtype=bool) Array([[False, False, False], [False, False, False]], dtype=bool)
fill_value may also be an array that is broadcast to the specified shape:
>>> jnp.full((2, 3), fill_value=jnp.arange(3)) Array([[0, 1, 2], [0, 1, 2]], dtype=int32)