You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs_nnx/nnx_basics.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ class Linear(nnx.Module):
40
40
self.din, self.dout = din, dout
41
41
42
42
def __call__(self, x: jax.Array):
43
-
return x @ self.w + self.b
43
+
return x @ self.w + self.b[None]
44
44
```
45
45
46
46
Also note that the inner values of `Variable`s can be accessed using the `value` property, but for convenience they implement all numeric operators and can be used directly in arithmetic expressions (as shown in the code above).
@@ -73,12 +73,12 @@ class Counter(nnx.Module):
73
73
self.count = Count(jnp.array(0))
74
74
75
75
def __call__(self):
76
-
self.count.value += 1
76
+
self.count[...] += 1
77
77
78
78
counter = Counter()
79
-
print(f'{counter.count.value = }')
79
+
print(f'{counter.count[...] = }')
80
80
counter()
81
-
print(f'{counter.count.value = }')
81
+
print(f'{counter.count[...] = }')
82
82
```
83
83
84
84
Mutable references are usually avoided in JAX. But Flax NNX provides sound mechanisms
0 commit comments