jax.numpy.logspace#
- jax.numpy.logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0)[源文件]#
生成对数等距值。
JAX 对
numpy.logspace()
的实现。- 参数:
start (Array | ndarray | bool | number | bool | int | float | complex) – 标量或数组。用于指定起始值。起始值为
base ** start
。stop (Array | ndarray | bool | number | bool | int | float | complex) – 标量或数组。用于指定结束值。结束值为
base ** stop
。num (int) – int 类型,可选,默认值=50。要生成的值的数量。
endpoint (bool) – bool 类型,可选,默认值=True。如果为 True,则结果中包含
stop
值。如果为 False,则排除stop
值。base (Array | ndarray | bool | number | bool | int | float | complex) – 标量或数组,可选,默认值=10。指定对数的底。
dtype (str | type[Any] | dtype | SupportsDType | None) – 可选。指定输出的数据类型。
axis (int) – int 类型,可选,默认值=0。生成对数等距值的轴。
- 返回:
对数数组。
- 返回类型:
另请参阅
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
) 之间的 7 个以 2 为底的对数等距值>>> 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)