A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.jax.dev/en/latest/_autosummary/jax.numpy.ones_like.html below:

jax.numpy.ones_like — JAX documentation

jax.numpy.ones_like#
jax.numpy.ones_like(a, dtype=None, shape=None, *, device=None)[source]#

Create an array of ones with the same shape and dtype as an array.

JAX implementation of numpy.ones_like().

Parameters:
  • a (Array | ndarray | bool | number | bool | int | float | complex | DuckTypedArray) – Array-like object with shape and dtype attributes.

  • shape (Any | None) – optionally override the shape of the created array.

  • dtype (str | type[Any] | dtype | SupportsDType | None) – optionally override the dtype of the created array.

  • device (Device | Sharding | None) – (optional) Device or Sharding to which the created array will be committed.

Returns:

Array of the specified shape and dtype, on the specified device if specified.

Return type:

Array

Examples

>>> x = jnp.arange(4)
>>> jnp.ones_like(x)
Array([1, 1, 1, 1], dtype=int32)
>>> jnp.ones_like(x, dtype=bool)
Array([ True,  True,  True,  True], dtype=bool)
>>> jnp.ones_like(x, shape=(2, 3))
Array([[1, 1, 1],
       [1, 1, 1]], dtype=int32)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3