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.ptp.html below:

jax.numpy.ptp — JAX documentation

jax.numpy.ptp#
jax.numpy.ptp(a, axis=None, out=None, keepdims=False)[source]#

Return the peak-to-peak range along a given axis.

JAX implementation of numpy.ptp().

Parameters:
  • a (ArrayLike) – input array.

  • axis (Axis) – optional, int or sequence of ints, default=None. Axis along which the range is computed. If None, the range is computed on the flattened array.

  • keepdims (bool) – bool, default=False. If true, reduced axes are left in the result with size 1.

  • out (None) – Unused by JAX.

Returns:

An array with the range of elements along specified axis of input.

Return type:

Array

Examples

By default, jnp.ptp computes the range along all axes.

>>> x = jnp.array([[1, 3, 5, 2],
...                [4, 6, 8, 1],
...                [7, 9, 3, 4]])
>>> jnp.ptp(x)
Array(8, dtype=int32)

If axis=1, computes the range along axis 1.

>>> jnp.ptp(x, axis=1)
Array([4, 7, 6], dtype=int32)

To preserve the dimensions of input, you can set keepdims=True.

>>> jnp.ptp(x, axis=1, keepdims=True)
Array([[4],
       [7],
       [6]], 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.4