Skip to main content

Python class

ModuleList

ModuleList

class max.experimental.nn.ModuleList(iterable=(), /)

source

Bases: list[T], Module

A Module subclass which is locally a list container.

ModuleList instances will use the stringified integer index of their submodules as the name of the module for the purposes of qualified paths.

For example:

from max.experimental.nn import Linear, Sequential

model = Sequential(
    Linear(5, 10),
    Linear(10, 5),
)

assert dict(model.parameters).keys() == {
    "0.weight", "0.bias", "1.weight", "1.bias"
}

children

property children: Iterable[tuple[str, Module[..., Any]]]

source

Iterates over the direct child modules of the Module.

Yields:

(name, module) pairs, where name is the attribute name of the child on the module.