mlx.nn.init.uniform

目錄

mlx.nn.init.uniform#

uniform(low: float = 0.0, high: float = 1.0, dtype: Dtype = mlx.core.float32) Callable[[array], array]#

An initializer that returns samples from a uniform distribution.

參數:
  • low (float, optional) -- The lower bound of the uniform distribution. Default: 0.0.

  • high (float, optional) -- The upper bound of the uniform distribution. Default: 1.0

  • dtype (Dtype, optional) -- The data type of the array. Default: float32.

回傳:

An initializer that returns an array with the same shape as the input, filled with samples from a uniform distribution

回傳型別:

Callable[[array], array]

範例

>>> init_fn = nn.init.uniform(low=0, high=1)
>>> init_fn(mx.zeros((2, 2)))
array([[0.883935, 0.863726],
       [0.617261, 0.417497]], dtype=float32)