jax.numpy.geomspace#
- jax.numpy.geomspace(start, stop, num=50, endpoint=True, dtype=None, axis=0)[原始碼]#
產生幾何級數間隔的值。
JAX 實作的
numpy.geomspace()
。- 參數:
- 回傳值:
包含幾何級數間隔值的陣列。
- 回傳型別:
另請參閱
jax.numpy.arange()
:產生N
個均勻間隔的值,給定起始點和步進值。jax.numpy.linspace()
:產生均勻間隔的值。jax.numpy.logspace()
:產生對數間隔的值。
範例
列出 1 到 16 之間 5 個幾何級數間隔的值
>>> with jnp.printoptions(precision=3, suppress=True): ... jnp.geomspace(1, 16, 5) Array([ 1., 2., 4., 8., 16.], dtype=float32)
列出 1 到 16 之間 4 個幾何級數間隔的值,且
endpoint=False
>>> with jnp.printoptions(precision=3, suppress=True): ... jnp.geomspace(1, 16, 4, endpoint=False) Array([1., 2., 4., 8.], dtype=float32)
多維 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)