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

Upgrade Flax NNX Filters doc #4199

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

8bitmp3
Copy link
Collaborator

@8bitmp3 8bitmp3 commented Sep 16, 2024

No description provided.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -31,28 +37,29 @@ print(f'{params = }')
print(f'{batch_stats = }')
```

Here `nnx.Param` and `nnx.BatchStat` are used as Filters to split the model into two groups: one with the parameters and the other with the batch statistics. However, this begs the following questions:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree removing this explanation. Can you explain why its removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not removed - it's above the code block on line 22. LMKWYT.

In the following example [`nnx.Param`](https://flax.readthedocs.io/en/latest/api_reference/flax.nnx/variables.html#flax.nnx.Param)
and [`nnx.BatchStat`](https://flax.readthedocs.io/en/latest/api_reference/flax.nnx/variables.html#flax.nnx.BatchStat)
are used as `Filter`s to split the model into two groups: one
with the parameters and the other with the batch statistics:


  ```{code-cell} ipython3
  from flax import nnx
  class Foo(nnx.Module):
    def __init__(self):
      self.a = nnx.Param(0)
      self.b = nnx.BatchStat(True)
  foo = Foo()
  graphdef, params, batch_stats = nnx.split(foo, nnx.Param, nnx.BatchStat)
  print(f'{params = }')
  print(f'{batch_stats = }')

@cgarciae 

@@ -8,12 +8,18 @@ jupytext:
jupytext_version: 1.13.8
---

# Using Filters
# Using `Filter`s
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove codefont Markdown formatting from section titles similar to Flax Basics @cgarciae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants