mlx.nn.init.constant

目錄

mlx.nn.init.constant#

constant(value: float, dtype: Dtype = mlx.core.float32) Callable[[array], array]#

An initializer that returns an array filled with value.

參數:
  • value (float) -- The value to fill the array with.

  • 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 value.

回傳型別:

Callable[[array], array]

範例

>>> init_fn = nn.init.constant(0.5)
>>> init_fn(mx.zeros((2, 2)))
array([[0.5, 0.5],
       [0.5, 0.5]], dtype=float32)