Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NNX Module set_attributes docs in module.py #4444

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions flax/nnx/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ def set_attributes(
raise_if_not_found: bool = True,
**attributes: tp.Any,
) -> None:
"""Sets the attributes of nested Modules including the current Module.
If the attribute is not found in the Module, it is ignored.
"""Sets the attributes of nested :class:`flax.nnx.Module`'s including the current
``nnx.Module``. If the attribute is not found in the ``nnx.Module``, it is ignored.

Example::

Expand All @@ -288,7 +288,8 @@ def set_attributes(
>>> block.dropout.deterministic, block.batch_norm.use_running_average
(True, True)

``Filter``'s can be used to set the attributes of specific Modules::
``Filter``'s (``flax.nnx.filterlib``) can be used to set the attributes of specific
``nnx.Module``'s::

>>> block = Block(2, 5, rngs=nnx.Rngs(0))
>>> block.set_attributes(nnx.Dropout, deterministic=True)
Expand All @@ -297,8 +298,8 @@ def set_attributes(
(True, False)

Args:
*filters: Filters to select the Modules to set the attributes of.
raise_if_not_found: If True (default), raises a ValueError if at least one attribute
*filters: NNX ``Filter``'s to select the :class:`flax.nnx.Module`'s whose attributes will be to be set.
raise_if_not_found: If ``True`` (default), raises a ValueError if at least one attribute
instance is not found in one of the selected Modules.
**attributes: The attributes to set.
"""
Expand Down
Loading