jax.numpy.ones#
- jax.numpy.ones(shape, dtype=None, *, device=None)[source]#
Create an array full of ones.
JAX implementation of
numpy.ones().- Parameters:
shape (Any) – int or sequence of ints specifying the shape of the created array.
dtype (DTypeLike | None | None) – optional dtype for the created array; defaults to floating point.
device (xc.Device | Sharding | None | None) – (optional)
DeviceorShardingto 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.ones(4) Array([1., 1., 1., 1.], dtype=float32) >>> jnp.ones((2, 3), dtype=bool) Array([[ True, True, True], [ True, True, True]], dtype=bool)