mlx.nn.init.constant#
- constant(value: float, dtype: Dtype = mlx.core.float32) Callable[[array], array] #
An initializer that returns an array filled with
value
.- Parameters:
- Returns:
An initializer that returns an array with the same shape as the input, filled with
value
.- Return type:
Example
>>> init_fn = nn.init.constant(0.5) >>> init_fn(mx.zeros((2, 2))) array([[0.5, 0.5], [0.5, 0.5]], dtype=float32)