← Prompts
Reference / Understand System Prompts Collection

.. currentmodule:: mlx.nn.init

.. _init: .. currentmodule:: mlx.nn.init Initializers ------------ The ``mlx.nn.init`` package contains commonly used initializers for neural network parameters. Initializers return a function whic

.. _init:

.. currentmodule:: mlx.nn.init

Initializers
------------

The ``mlx.nn.init`` package contains commonly used initializers for neural
network parameters. Initializers return a function which can be applied to any
input :obj:`mlx.core.array` to produce an initialized output.

For example:

.. code:: python

   import mlx.core as mx
   import mlx.nn as nn

   init_fn = nn.init.uniform()

   # Produces a [2, 2] uniform matrix
   param = init_fn(mx.zeros((2, 2)))

To re-initialize all the parameter in an :obj:`mlx.nn.Module` from say a uniform 
distribution, you can do:

Sign in to view the full prompt.

Sign In

Classification

Reference Documentation, cheatsheets, setup guides
Reference Understand
Explain or analyze
Scope Project
This codebase
Manual Manually placed / Persistent