jax.random.ball#

jax.random.ball(key, d, p=2, shape=(), dtype=None)[源码]#

从单位 Lp 球体中均匀采样。

参考: https://arxiv.org/abs/math/0503650.

参数:
  • key (ArrayLike) – 用作随机密钥的 PRNG 密钥。

  • d (int) – 一个非负整数,表示球体的维度。

  • p (float) – 一个浮点数,表示 Lp 范数的 p 参数。

  • shape (Shape) – 可选,结果的批量维度。默认为 ()。

  • dtype (DTypeLikeFloat | None) – 可选,返回值的浮点数 dtype(如果 jax_enable_x64 为 true,则默认为 float64,否则为 float32)。

返回:

一个形状为 (*shape, d) 且具有指定 dtype 的随机数组。