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

[nnx] Fix nnx basics #3812

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions docs/experimental/nnx/nnx_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
}
],
"source": [
"state, static = model.split()\n",
"static, state = model.split()\n",
"\n",
"print(f'{state = }\\n')\n",
"print(f'{static = }'[:200] + '...')"
Expand Down Expand Up @@ -450,7 +450,7 @@
"print(f'{model.count = }')\n",
"\n",
"# 1. Use split to create a pytree representation of the Module\n",
"state, static = model.split()\n",
"static, state = model.split()\n",
"\n",
"@jax.jit\n",
"def forward(static: nnx.GraphDef, state: nnx.State, x: jax.Array):\n",
Expand Down Expand Up @@ -532,7 +532,7 @@
],
"source": [
"# use Variable type filters to split into multiple States\n",
"params, counts, static = model.split(nnx.Param, Count)\n",
"static, params, counts = model.split(nnx.Param, Count)\n",
"\n",
"print(f'{params = }\\n')\n",
"print(f'{counts = }')"
Expand Down
6 changes: 3 additions & 3 deletions docs/experimental/nnx/nnx_basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ a Module graph, its analogous to JAX's `PyTreeDef`, and for convenience it
implements an empty pytree.

```{code-cell} ipython3
state, static = model.split()
static, state = model.split()

print(f'{state = }\n')
print(f'{static = }'[:200] + '...')
Expand All @@ -222,7 +222,7 @@ updates from a transform back to the source object outside.
print(f'{model.count = }')

# 1. Use split to create a pytree representation of the Module
state, static = model.split()
static, state = model.split()

@jax.jit
def forward(static: nnx.GraphDef, state: nnx.State, x: jax.Array):
Expand Down Expand Up @@ -269,7 +269,7 @@ Variable types as shown below.

```{code-cell} ipython3
# use Variable type filters to split into multiple States
params, counts, static = model.split(nnx.Param, Count)
static, params, counts = model.split(nnx.Param, Count)

print(f'{params = }\n')
print(f'{counts = }')
Expand Down
Loading