jax.numpy.geomspace#

jax.numpy.geomspace(start, stop, num=50, endpoint=True, dtype=None, axis=0)[source]#

Generate geometrically-spaced values.

JAX implementation of numpy.geomspace().

Parameters:
  • start (ArrayLike) – scalar or array. Specifies the starting values.

  • stop (ArrayLike) – scalar or array. Specifies the stop values.

  • num (int) – int, optional, default=50. Number of values to generate.

  • endpoint (bool) – bool, optional, default=True. If True, then include the stop value in the result. If False, then exclude the stop value.

  • dtype (DTypeLike | None | None) – optional. Specifies the dtype of the output.

  • axis (int) – int, optional, default=0. Axis along which to generate the geomspace.

Returns:

An array containing the geometrically-spaced values.

Return type:

Array

See also

Examples

List 5 geometrically-spaced values between 1 and 16:

>>> with jnp.printoptions(precision=3, suppress=True):
...   jnp.geomspace(1, 16, 5)
Array([ 1.,  2.,  4.,  8., 16.], dtype=float32)

List 4 geomtrically-spaced values between 1 and 16, with endpoint=False:

>>> with jnp.printoptions(precision=3, suppress=True):
...   jnp.geomspace(1, 16, 4, endpoint=False)
Array([1., 2., 4., 8.], dtype=float32)

Multi-dimensional geomspace:

>>> start = jnp.array([1, 1000])
>>> stop = jnp.array([27, 1])
>>> with jnp.printoptions(precision=3, suppress=True):
...   jnp.geomspace(start, stop, 4)
Array([[   1., 1000.],
       [   3.,  100.],
       [   9.,   10.],
       [  27.,    1.]], dtype=float32)