jax.numpy.logspace#
- jax.numpy.logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0)[原始碼]#
產生對數間隔值。
JAX 版本的
numpy.logspace()
。- 參數:
start (ArrayLike) – 純量或陣列。用於指定起始值。起始值為
base ** start
。stop (ArrayLike) – 純量或陣列。用於指定停止值。終止值為
base ** stop
。num (int) – int,可選,預設值=50。要產生的值數量。
endpoint (bool) – bool,可選,預設值=True。如果為 True,則在結果中包含
stop
值。如果為 False,則排除stop
值。base (ArrayLike) – 純量或陣列,可選,預設值=10。指定對數的底數。
dtype (DTypeLike | None | None) – 可選。指定輸出的 dtype。
axis (int) – int,可選,預設值=0。產生 logspace 的軸。
- 回傳:
對數陣列。
- 回傳型別:
另請參閱
jax.numpy.arange()
:產生給定起點和步進值的N
個均勻間隔值。jax.numpy.linspace()
:產生均勻間隔值。jax.numpy.geomspace()
:產生幾何間隔值。
範例
列出 1 (
10 ** 0
) 和 100 (10 ** 2
) 之間 5 個對數間隔值>>> with jnp.printoptions(precision=3, suppress=True): ... jnp.logspace(0, 2, 5) Array([ 1. , 3.162, 10. , 31.623, 100. ], dtype=float32)
列出 1(
10 ** 0
) 和 100 (10 ** 2
) 之間 5 個對數間隔值,排除端點>>> with jnp.printoptions(precision=3, suppress=True): ... jnp.logspace(0, 2, 5, endpoint=False) Array([ 1. , 2.512, 6.31 , 15.849, 39.811], dtype=float32)
列出 1 (
2 ** 0
) 和 4 (2 ** 2
) 之間以 2 為底的 7 個對數間隔值>>> with jnp.printoptions(precision=3, suppress=True): ... jnp.logspace(0, 2, 7, base=2) Array([1. , 1.26 , 1.587, 2. , 2.52 , 3.175, 4. ], dtype=float32)
多維對數空間
>>> start = jnp.array([0, 5]) >>> stop = jnp.array([5, 0]) >>> base = jnp.array([2, 3]) >>> with jnp.printoptions(precision=3, suppress=True): ... jnp.logspace(start, stop, 5, base=base) Array([[ 1. , 243. ], [ 2.378, 61.547], [ 5.657, 15.588], [ 13.454, 3.948], [ 32. , 1. ]], dtype=float32)