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) | |