File size: 476 Bytes
900cef8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from flax import nnx # The Flax NNX API.
class LinearClassifier(nnx.Module):
def __init__(self, in_features, out_features, rngs: nnx.Rngs):
self.linear = nnx.Linear(in_features, out_features, rngs=rngs)
def __call__(self, x):
return self.linear(x)
if __name__ == "__main__":
# Instantiate the model.
model = LinearClassifier(
in_features=512,
out_features=8,
rngs=nnx.Rngs(0)
)
# Visualize it.
nnx.display(model)
|