mlx.core.random.uniform

内容

mlx.core.random.uniform#

uniform(low: scalar | array = 0, high: scalar | array = 1, shape: Sequence[int] = [], dtype: Dtype | None = float32, key: array | None = None, stream: None | Stream | Device = None) array#

生成均匀分布的随机数。

这些值在半开区间 [low, high) 内均匀采样。下限和上限可以是标量或数组,并且必须能广播到 shape

参数:
  • low (scalararray, 可选) – 分布的下限。默认值: 0

  • high (scalararray, 可选) – 分布的上限。默认值: 1

  • shape (list(int), 可选) – 输出的形状。默认值: ()

  • dtype (Dtype, 可选) – 输出的数据类型。默认值: float32

  • key (array, 可选) – PRNG 键。默认值: None

返回:

包含随机值的输出数组。

返回类型:

array