mlx.nn.Module.apply#
- Module.apply(map_fn: Callable[[array], array], filter_fn: Callable[[Module, str, Any], bool] | None = None) Module#
Map all the parameters using the provided
map_fnand immediately update the module with the mapped parameters.For instance running
model.apply(lambda x: x.astype(mx.float16))casts all parameters to 16 bit floats.- 參數:
map_fn (Callable) -- Maps an array to another array
filter_fn (Callable, optional) -- Filter to select which arrays to map (default:
Module.valid_parameter_filter()).
- 回傳:
The module instance after updating the parameters.