Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K
JAX  documentation - Home

jax.numpy.ptp

Contents

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 ofnumpy.ptp().

Parameters:
  • a (ArrayLike) – input array.

  • axis (Axis) – optional, int or sequence of ints, default=None. Axis along which therange 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 resultwith 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)

Ifaxis=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 setkeepdims=True.

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

[8]ページ先頭

©2009-2025 Movatter.jp