mlx.nn.init.normal

目录

mlx.nn.init.normal#

normal(mean: float = 0.0, std: float = 1.0, dtype: Dtype = mlx.core.float32) Callable[[array], array]#

An initializer that returns samples from a normal distribution.

参数:
  • mean (float, optional) -- Mean of the normal distribution. Default: 0.0.

  • std (float, optional) -- Standard deviation of the normal 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 normal distribution.

返回类型:

Callable[[array], array]

示例

>>> init_fn = nn.init.normal()
>>> init_fn(mx.zeros((2, 2)))
array([[-0.982273, -0.534422],
       [0.380709, 0.0645099]], dtype=float32)