Files
mlx/docs/build/doctrees/python/nn/module.doctree

187 lines
35 KiB
Plaintext
Raw Normal View History

2024-01-17 17:15:29 -08:00
<EFBFBD><05><><EFBFBD><00>sphinx.addnodes<65><73>document<6E><74><EFBFBD>)<29><>}<7D>(<28> rawsource<63><65><00><>children<65>]<5D><>docutils.nodes<65><73>section<6F><6E><EFBFBD>)<29><>}<7D>(hhh]<5D>(h <09>title<6C><65><EFBFBD>)<29><>}<7D>(h<05>Module<6C>h]<5D>h <09>Text<78><74><EFBFBD><EFBFBD>Module<6C><65><EFBFBD><EFBFBD><EFBFBD>}<7D>(<28>parent<6E>h<11> _document<6E>h<03>source<63>N<EFBFBD>line<6E>Nuba<62>
attributes<EFBFBD>}<7D>(<28>ids<64>]<5D><>classes<65>]<5D><>names<65>]<5D><>dupnames<65>]<5D><>backrefs<66>]<5D>u<EFBFBD>tagname<6D>hhh hhh<1D>9/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst<73>hKubh<00>index<65><78><EFBFBD>)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>entries<65>]<5D>(<28>single<6C><65>Module (class in mlx.nn)<29><> mlx.nn.Module<6C>hNt<4E>auh+h-hh hhhNhNubh<00>desc<73><63><EFBFBD>)<29><>}<7D>(hhh]<5D>(h<00>desc_signature<72><65><EFBFBD>)<29><>}<7D>(h<05>Module()<29>h]<5D>(h<00>desc_annotation<6F><6E><EFBFBD>)<29><>}<7D>(h<05>2[<#text: 'class'>, <desc_sig_space: <#text: ' '>>]<5D>h]<5D>(h<16>class<73><73><EFBFBD><EFBFBD><EFBFBD>}<7D>(hhKhhhNhNubh<00>desc_sig_space<63><65><EFBFBD>)<29><>}<7D>(h<05> <20>h]<5D>h<16> <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hhUhhhNhNubah}<7D>(h!]<5D>h#]<5D><>w<>ah%]<5D>h']<5D>h)]<5D>uh+hShhKubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><> xml:space<63><65>preserve<76>uh+hIhhEhhh<1D>_/Users/awnihannun/repos/mlx/python/mlx/nn/layers/base.py:docstring of mlx.nn.layers.base.Module<6C>hNubh<00> desc_addname<6D><65><EFBFBD>)<29><>}<7D>(h<05>mlx.nn.<2E>h]<5D>h<16>mlx.nn.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hhohhhNhNubah}<7D>(h!]<5D>h#]<5D>(<28> sig-prename<6D><65> descclassname<6D>eh%]<5D>h']<5D>h)]<5D>hjhkuh+hmhhEhhhhlhNubh<00> desc_name<6D><65><EFBFBD>)<29><>}<7D>(h<05>Module<6C>h]<5D>h<16>Module<6C><65><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>(<28>sig-name<6D><65>descname<6D>eh%]<5D>h']<5D>h)]<5D>hjhkuh+hhhEhhhhlhNubeh}<7D>(h!]<5D>h<ah#]<5D>(<28>sig<69><67>
sig-object<63>eh%]<5D>h']<5D>h)]<5D><>module<6C><65>mlx.nn<6E><6E>class<73>h<06>fullname<6D>h<EFBFBD>uh+hCh<1D>_/Users/awnihannun/repos/mlx/python/mlx/nn/layers/base.py:docstring of mlx.nn.layers.base.Module<6C>hKhh@hhubh<00> desc_content<6E><74><EFBFBD>)<29><>}<7D>(hhh]<5D>(h <09> paragraph<70><68><EFBFBD>)<29><>}<7D>(h<05>1Base class for building neural networks with MLX.<2E>h]<5D>h<16>1Base class for building neural networks with MLX.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>h<1D>_/Users/awnihannun/repos/mlx/python/mlx/nn/layers/base.py:docstring of mlx.nn.layers.base.Module<6C>hKhh<>hhubh<62>)<29><>}<7D>(h<05>gAll the layers provided in :mod:`mlx.nn.layers` subclass this class and
your models should do the same.<2E>h]<5D>(h<16>All the layers provided in <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubh<00> pending_xref<65><66><EFBFBD>)<29><>}<7D>(h<05>:mod:`mlx.nn.layers`<60>h]<5D>h <09>literal<61><6C><EFBFBD>)<29><>}<7D>(hh<>h]<5D>h<16> mlx.nn.layers<72><73><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>(<28>xref<65><66>py<70><79>py-mod<6F>eh%]<5D>h']<5D>h)]<5D>uh+h<>hh<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F><63>python/nn/module<6C><65> refdomain<69>reftype<70><65>mod<6F><64> refexplicit<69><74><EFBFBD>refwarn<72><6E><EFBFBD> py:module<6C>h<EFBFBD><68>py:class<73>h<EFBFBD><68> reftarget<65><74> mlx.nn.layers<72>uh+h<>hh<>hKhh<>ubh<16>8 subclass this class and
your models should do the same.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hh<>hKhh<>hhubh<62>)<29><>}<7D>(hX A ``Module`` can contain other ``Module`` instances or :class:`mlx.core.array`
instances in arbitrary nesting of python lists or dicts. The ``Module``
then allows recursively extracting all the :class:`mlx.core.array` instances
using :meth:`mlx.nn.Module.parameters`.<2E>h]<5D>(h<16>A <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubh<62>)<29><>}<7D>(h<05>
``Module``<60>h]<5D>h<16>Module<6C><65><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hh<>ubh<16> can contain other <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubh<62>)<29><>}<7D>(h<05>
``Module``<60>h]<5D>h<16>Module<6C><65><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hh<>ubh<16> instances or <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubh<62>)<29><>}<7D>(h<05>:class:`mlx.core.array`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hjh]<5D>h<16>mlx.core.array<61><79><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjhhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-class<73>eh%]<5D>h']<5D>h)]<5D>uh+h<>hjubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j)<00>reftype<70><65>class<73><73> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.core.array<61>uh+h<>hh<>hKhh<>ubh<16>>
instances in arbitrary nesting of python lists or dicts. The <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubh<62>)<29><>}<7D>(h<05>
``Module``<60>h]<5D>h<16>Module<6C><65><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj?hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hh<>ubh<16>,
then allows recursively extracting all the <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubh<62>)<29><>}<7D>(h<05>:class:`mlx.core.array`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hjSh]<5D>h<16>mlx.core.array<61><79><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjUhhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-class<73>eh%]<5D>h']<5D>h)]<5D>uh+h<>hjQubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j_<00>reftype<70><65>class<73><73> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.core.array<61>uh+h<>hh<>hKhh<>ubh<16> instances
using <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubh<62>)<29><>}<7D>(h<05> :meth:`mlx.nn.Module.parameters`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hjwh]<5D>h<16>mlx.nn.Module.parameters()<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjyhhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-meth<74>eh%]<5D>h']<5D>h)]<5D>uh+h<>hjuubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j<EFBFBD><00>reftype<70><65>meth<74><68> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.Module.parameters<72>uh+h<>hh<>hKhh<>ubh<16>.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hh<>hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hh<>hKhh<>hhubh<62>)<29><>}<7D>(hXEIn addition, the ``Module`` has the concept of trainable and non trainable
parameters (called "frozen"). When using :func:`mlx.nn.value_and_grad`
the gradients are returned only with respect to the trainable parameters.
All arrays in a module are trainable unless they are added in the "frozen"
set by calling :meth:`freeze`.<2E>h]<5D>(h<16>In addition, the <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubh<62>)<29><>}<7D>(h<05>
``Module``<60>h]<5D>h<16>Module<6C><65><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj<>ubh<16>] has the concept of trainable and non trainable
parameters (called “frozen”). When using <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubh<62>)<29><>}<7D>(h<05>:func:`mlx.nn.value_and_grad`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hj<>h]<5D>h<16>mlx.nn.value_and_grad()<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-func<6E>eh%]<5D>h']<5D>h)]<5D>uh+h<>hj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j<EFBFBD><00>reftype<70><65>func<6E><63> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.value_and_grad<61>uh+h<>hh<>hK hj<>ubh<16><>
the gradients are returned only with respect to the trainable parameters.
All arrays in a module are trainable unless they are added in the “frozen”
set by calling <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubh<62>)<29><>}<7D>(h<05>:meth:`freeze`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hj<>h]<5D>h<16>freeze()<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-meth<74>eh%]<5D>h']<5D>h)]<5D>uh+h<>hj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j<EFBFBD><00>reftype<70><65>meth<74><68> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>freeze<7A>uh+h<>hh<>hK hj<>ubh<16>.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hh<>hK hh<>hhubh <09> literal_block<63><6B><EFBFBD>)<29><>}<7D>(hX4import mlx.core as mx
import mlx.nn as nn
class MyMLP(nn.Module):
def __init__(self, in_dims: int, out_dims: int, hidden_dims: int = 16):
super().__init__()
self.in_proj = nn.Linear(in_dims, hidden_dims)
self.out_proj = nn.Linear(hidden_dims, out_dims)
def __call__(self, x):
x = self.in_proj(x)
x = mx.maximum(x, 0)
return self.out_proj(x)
model = MyMLP(2, 1)
# All the model parameters are created but since MLX is lazy by
# default, they are not evaluated yet. Calling `mx.eval` actually
# allocates memory and initializes the parameters.
mx.eval(model.parameters())
# Setting a parameter to a new value is as simply as accessing that
# parameter and assigning a new array to it.
model.in_proj.weight = model.in_proj.weight * 2
mx.eval(model.parameters())<29>h]<5D>hX4import mlx.core as mx
import mlx.nn as nn
class MyMLP(nn.Module):
def __init__(self, in_dims: int, out_dims: int, hidden_dims: int = 16):
super().__init__()
self.in_proj = nn.Linear(in_dims, hidden_dims)
self.out_proj = nn.Linear(hidden_dims, out_dims)
def __call__(self, x):
x = self.in_proj(x)
x = mx.maximum(x, 0)
return self.out_proj(x)
model = MyMLP(2, 1)
# All the model parameters are created but since MLX is lazy by
# default, they are not evaluated yet. Calling `mx.eval` actually
# allocates memory and initializes the parameters.
mx.eval(model.parameters())
# Setting a parameter to a new value is as simply as accessing that
# parameter and assigning a new array to it.
model.in_proj.weight = model.in_proj.weight * 2
mx.eval(model.parameters())<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>hj sbah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>hjhk<68>force<63><65><EFBFBD>language<67><65>python<6F><6E>highlight_args<67>}<7D>uh+jhh<>hKhh<>hhubh <09>rubric<69><63><EFBFBD>)<29><>}<7D>(h<05>
Attributes<EFBFBD>h]<5D>h<16>
Attributes<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjhhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jhh<>hhhh,hK ubh<00>tabular_col_spec<65><63><EFBFBD>)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>spec<65><63>\X{1}{2}\X{1}{2}<7D>uh+j,hh<>hhh<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:14:<autosummary><3E>hNub<75>sphinx.ext.autosummary<72><79>autosummary_table<6C><65><EFBFBD>)<29><>}<7D>(h<05>I
Module.training
Boolean indicating if the model is in training mode.<2E>h]<5D>h <09>table<6C><65><EFBFBD>)<29><>}<7D>(hhh]<5D>h <09>tgroup<75><70><EFBFBD>)<29><>}<7D>(hhh]<5D>(h <09>colspec<65><63><EFBFBD>)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>colwidth<74>K
uh+jKhjHubjL)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>colwidth<74>KZuh+jKhjHubh <09>tbody<64><79><EFBFBD>)<29><>}<7D>(hhh]<5D>h <09>row<6F><77><EFBFBD>)<29><>}<7D>(hhh]<5D>(h <09>entry<72><79><EFBFBD>)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>3:py:obj:`Module.training <mlx.nn.Module.training>`\<5C>h]<5D>(h<>)<29><>}<7D>(h<05>2:py:obj:`Module.training <mlx.nn.Module.training>`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hjvh]<5D>h<16>Module.training<6E><67><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjxhhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-obj<62>eh%]<5D>h']<5D>h)]<5D>uh+h<>hjtubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j<EFBFBD><00>reftype<70><65>obj<62><6A> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.Module.training<6E>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:14:<autosummary><3E>hKhjpubhh<06><><EFBFBD><EFBFBD>}<7D>(hjphhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj<>hKhjmubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhjhubjl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>4Boolean indicating if the model is in training mode.<2E>h]<5D>h<16>4Boolean indicating if the model is in training mode.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj9hKhj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhjhubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jfhjcubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jahjHubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>cols<6C>Kuh+jFhjCubah}<7D>(h!]<5D>h#]<5D><>autosummary longtable<6C>ah%]<5D>h']<5D>h)]<5D>uh+jAhj=ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>hjhkuh+j;hh<>hhhj9hNubj:<00>autosummary_toc<6F><63><EFBFBD>)<29><>}<7D>(hhh]<5D>h<00>toctree<65><65><EFBFBD>)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><> includefiles<65>]<5D><>-python/nn/_autosummary/mlx.nn.Module.training<6E>a<EFBFBD>entries<65>]<5D>Nj<4E><00><>a<EFBFBD>maxdepth<74>J<EFBFBD><4A><EFBFBD><EFBFBD><EFBFBD>glob<6F>N<EFBFBD>caption<6F>N<EFBFBD>
rawentries<EFBFBD>]<5D>uh+j<>hj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>hjhkuh+j<>hh<>hhhj9hNubj)<29><>}<7D>(h<05>Methods<64>h]<5D>h<16>Methods<64><73><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jhh<>hhhh,hKubj-)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>j7j8uh+j,hh<>hhh<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hNubj<)<29><>}<7D>(hX<>
Module.apply(map_fn[, filter_fn])
Map all the parameters using the provided map_fn and immediately update the module with the mapped parameters.
Module.apply_to_modules(apply_fn)
Apply a function to all the modules in this instance (including this instance).
Module.children()
Return the direct descendants of this Module instance.
Module.eval()
Set the model to evaluation mode.
Module.filter_and_map(filter_fn[, map_fn, ...])
Recursively filter the contents of the module using filter_fn, namely only select keys and values where filter_fn returns true.
Module.freeze(*[, recurse, keys, strict])
Freeze the Module's parameters or some of them.
Module.leaf_modules()
Return the submodules that do not contain other modules.
Module.load_weights(file_or_weights[, strict])
Update the model's weights from a .npz or a list.
Module.modules()
Return a list with all the modules in this instance.
Module.named_modules()
Return a list with all the modules in this instance and their name with dot notation.
Module.parameters()
Recursively return all the mlx.core.array members of this Module as a dict of dicts and lists.
Module.save_weights(file)
Save the model's weights to a .npz file.
Module.train([mode])
Set the model in or out of training mode.
Module.trainable_parameters()
Recursively return all the non frozen mlx.core.array members of this Module as a dict of dicts and lists.
Module.unfreeze(*[, recurse, keys, strict])
Unfreeze the Module's parameters or some of them.
Module.update(parameters)
Replace the parameters of this Module with the provided ones in the dict of dicts and lists.
Module.update_modules(modules)
Replace the child modules of this Module instance with the provided ones in the dict of dicts and lists.<2E>h]<5D>jB)<29><>}<7D>(hhh]<5D>jG)<29><>}<7D>(hhh]<5D>(jL)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>colwidth<74>K
uh+jKhjubjL)<29><>}<7D>(hhh]<5D>h}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>colwidth<74>KZuh+jKhjubjb)<29><>}<7D>(hhh]<5D>(jg)<29><>}<7D>(hhh]<5D>(jl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>J:py:obj:`Module.apply <mlx.nn.Module.apply>`\ \(map\_fn\[\, filter\_fn\]\)<29>h]<5D>(h<>)<29><>}<7D>(h<05>,:py:obj:`Module.apply <mlx.nn.Module.apply>`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hjAh]<5D>h<16> Module.apply<6C><79><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjChhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-obj<62>eh%]<5D>h']<5D>h)]<5D>uh+h<>hj?ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>jM<00>reftype<70><65>obj<62><6A> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.Module.apply<6C>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj;ubh<16>(map_fn[, filter_fn])<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj;hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj_hKhj8ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj5ubjl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>rMap all the parameters using the provided ``map_fn`` and immediately update the module with the mapped parameters.<2E>h]<5D>(h<16>*Map all the parameters using the provided <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjshhhNhNubh<62>)<29><>}<7D>(h<05>
``map_fn``<60>h]<5D>h<16>map_fn<66><6E><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj{hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hjsubh<16>> and immediately update the module with the mapped parameters.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjshhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhjpubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj5ubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jfhj2ubjg)<29><>}<7D>(hhh]<5D>(jl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>Q:py:obj:`Module.apply_to_modules <mlx.nn.Module.apply_to_modules>`\ \(apply\_fn\)<29>h]<5D>(h<>)<29><>}<7D>(h<05>B:py:obj:`Module.apply_to_modules <mlx.nn.Module.apply_to_modules>`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hj<>h]<5D>h<16>Module.apply_to_modules<65><73><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-obj<62>eh%]<5D>h']<5D>h)]<5D>uh+h<>hj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j<EFBFBD><00>reftype<70><65>obj<62><6A> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.Module.apply_to_modules<65>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj<>ubh<16>
(apply_fn)<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj<>hKhj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj<>ubjl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>OApply a function to all the modules in this instance (including this instance).<2E>h]<5D>h<16>OApply a function to all the modules in this instance (including this instance).<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj<>ubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jfhj2ubjg)<29><>}<7D>(hhh]<5D>(jl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>8:py:obj:`Module.children <mlx.nn.Module.children>`\ \(\)<29>h]<5D>(h<>)<29><>}<7D>(h<05>2:py:obj:`Module.children <mlx.nn.Module.children>`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hjh]<5D>h<16>Module.children<65><6E><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjhhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-obj<62>eh%]<5D>h']<5D>h)]<5D>uh+h<>hjubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j<00>reftype<70><65>obj<62><6A> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.Module.children<65>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj<>ubh<16>()<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj#hKhj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj<>ubjl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>6Return the direct descendants of this Module instance.<2E>h]<5D>h<16>6Return the direct descendants of this Module instance.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj7hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj4ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj<>ubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jfhj2ubjg)<29><>}<7D>(hhh]<5D>(jl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>0:py:obj:`Module.eval <mlx.nn.Module.eval>`\ \(\)<29>h]<5D>(h<>)<29><>}<7D>(h<05>*:py:obj:`Module.eval <mlx.nn.Module.eval>`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hj^h]<5D>h<16> Module.eval<61><6C><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj`hhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-obj<62>eh%]<5D>h']<5D>h)]<5D>uh+h<>hj\ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>jj<00>reftype<70><65>obj<62><6A> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.Module.eval<61>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhjXubh<16>()<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjXhhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj|hKhjUubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhjRubjl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>!Set the model to evaluation mode.<2E>h]<5D>h<16>!Set the model to evaluation mode.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhjRubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jfhj2ubjg)<29><>}<7D>(hhh]<5D>(jl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05>b:py:obj:`Module.filter_and_map <mlx.nn.Module.filter_and_map>`\ \(filter\_fn\[\, map\_fn\, ...\]\)<29>h]<5D>(h<>)<29><>}<7D>(h<05>>:py:obj:`Module.filter_and_map <mlx.nn.Module.filter_and_map>`<60>h]<5D>h<EFBFBD>)<29><>}<7D>(hj<>h]<5D>h<16>Module.filter_and_map<61><70><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>(hΌpy<70><79>py-obj<62>eh%]<5D>h']<5D>h)]<5D>uh+h<>hj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>refdoc<6F>hی refdomain<69>j<EFBFBD><00>reftype<70><65>obj<62><6A> refexplicit<69><74><EFBFBD>refwarn<72><6E>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD>h<EFBFBD><68>mlx.nn.Module.filter_and_map<61>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj<>ubh<16>(filter_fn[, map_fn, ...])<29><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj<>hKhj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj<>ubjl)<29><>}<7D>(hhh]<5D>h<EFBFBD>)<29><>}<7D>(h<05><>Recursively filter the contents of the module using ``filter_fn``, namely only select keys and values where ``filter_fn`` returns true.<2E>h]<5D>(h<16>4Recursively filter the contents of the module using <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubh<62>)<29><>}<7D>(h<05> ``filter_fn``<60>h]<5D>h<16> filter_fn<66><6E><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj<>ubh<16>+, namely only select keys and values where <20><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubh<62>)<29><>}<7D>(h<05> ``filter_fn``<60>h]<5D>h<16> filter_fn<66><6E><EFBFBD><EFBFBD><EFBFBD>}<7D>(hjhhhNhNubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hj<>ubh<16> returns true.<2E><><EFBFBD><EFBFBD><EFBFBD>}<7D>(hj<>hhhNhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>h<1D>J/Users/awnihannun/repos/mlx/docs/src/python/nn/module.rst:36:<autosummary><3E>hKhj<>ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+jkhj<>ubeh}
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>Nj
<00><>ej<65>J<><4A><EFBFBD><EFBFBD>j<EFBFBD>Nj<4E>Nj<4E>]<5D>uh+j<>hj<> ubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>hjhkuh+j<>hh<>hhhjhNubeh}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D>uh+h<>hh@hhhhlhNubeh}<7D>(h!]<5D>h#]<5D>(<28>py<70><79>class<73>eh%]<5D>h']<5D>h)]<5D><>domain<69>j<
<00>objtype<70>j=
<00>desctype<70>j=
<00>noindex<65><78>uh+h>hhhh hNhNubeh}<7D>(h!]<5D><>module<6C>ah#]<5D>h%]<5D><>module<6C>ah']<5D>h)]<5D>uh+h
hhhhhh,hKubah}<7D>(h!]<5D>h#]<5D>h%]<5D>h']<5D>h)]<5D><>source<63>h,uh+h<01>current_source<63>N<EFBFBD> current_line<6E>N<EFBFBD>settings<67><73>docutils.frontend<6E><64>Values<65><73><EFBFBD>)<29><>}<7D>(hN<> generator<6F>N<EFBFBD> datestamp<6D>N<EFBFBD> source_link<6E>N<EFBFBD>
source_url<EFBFBD>N<EFBFBD> toc_backlinks<6B>jk<00>footnote_backlinks<6B>K<01> sectnum_xform<72>K<01>strip_comments<74>N<EFBFBD>strip_elements_with_classes<65>N<EFBFBD> strip_classes<65>N<EFBFBD> report_level<65>K<02>
halt_level<EFBFBD>K<05>exit_status_level<65>K<05>debug<75>N<EFBFBD>warning_stream<61>N<EFBFBD> traceback<63><6B><EFBFBD>input_encoding<6E><67> utf-8-sig<69><67>input_encoding_error_handler<65><72>strict<63><74>output_encoding<6E><67>utf-8<><38>output_encoding_error_handler<65>jo
<00>error_encoding<6E><67>utf-8<><38>error_encoding_error_handler<65><72>backslashreplace<63><65> language_code<64><65>en<65><6E>record_dependencies<65>N<EFBFBD>config<69>N<EFBFBD> id_prefix<69>h<06>auto_id_prefix<69><78>id<69><64> dump_settings<67>N<EFBFBD>dump_internals<6C>N<EFBFBD>dump_transforms<6D>N<EFBFBD>dump_pseudo_xml<6D>N<EFBFBD>expose_internals<6C>N<EFBFBD>strict_visitor<6F>N<EFBFBD>_disable_config<69>N<EFBFBD>_source<63>h,<2C> _destination<6F>N<EFBFBD> _config_files<65>]<5D><>file_insertion_enabled<65><64><EFBFBD> raw_enabled<65>K<01>line_length_limit<69>M'<27>pep_references<65>N<EFBFBD> pep_base_url<72><6C>https://peps.python.org/<2F><>pep_file_url_template<74><65>pep-%04d<34><64>rfc_references<65>N<EFBFBD> rfc_base_url<72><6C>&https://datatracker.ietf.org/doc/html/<2F><> tab_width<74>K<08>trim_footnote_reference_space<63><65><EFBFBD>syntax_highlight<68><74>long<6E><67> smart_quotes<65><73><EFBFBD>smartquotes_locales<65>]<5D><>character_level_inline_markup<75><70><EFBFBD>doctitle_xform<72><6D><EFBFBD> docinfo_xform<72>K<01>sectsubtitle_xform<72><6D><EFBFBD> image_loading<6E><67>link<6E><6B>embed_stylesheet<65><74><EFBFBD>cloak_email_addresses<65><73><EFBFBD>section_self_link<6E><6B><EFBFBD>env<6E>Nub<75>reporter<65>N<EFBFBD>indirect_targets<74>]<5D><>substitution_defs<66>}<7D><>substitution_names<65>}<7D><>refnames<65>}<7D><>refids<64>}<7D><>nameids<64>}<7D>jJ
jG
s<> nametypes<65>}<7D>jJ
<00>sh!}<7D>(jG
h h<hEu<45> footnote_refs<66>}<7D><> citation_refs<66>}<7D><> autofootnotes<65>]<5D><>autofootnote_refs<66>]<5D><>symbol_footnotes<65>]<5D><>symbol_footnote_refs<66>]<5D><> footnotes<65>]<5D><> citations<6E>]<5D><>autofootnote_start<72>K<01>symbol_footnote_start<72>K<00>
id_counter<EFBFBD><EFBFBD> collections<6E><73>Counter<65><72><EFBFBD>}<7D><><EFBFBD>R<EFBFBD><52>parse_messages<65>]<5D><>transform_messages<65>]<5D><> transformer<65>N<EFBFBD> include_log<6F>]<5D><>
decoration<EFBFBD>Nhhub.