brainstate.interop.from_nnx#
- brainstate.interop.from_nnx(model, *, sample_input=None)[source]#
Convert a
flax.nnxmodel into an equivalentbrainstate.nnmodel.- Parameters:
- Returns:
The converted model, weight-equivalent to
model.- Return type:
- Raises:
MissingDependencyError – If
flaxis not installed.UnmappedLayerError, UnsupportedLayerError, UnsupportedStructureError, MissingShapeError – See
brainstate.interoperror types.
Examples
>>> import brainstate as bst >>> from flax import nnx >>> src = nnx.Linear(3, 4, rngs=nnx.Rngs(0)) >>> dst = bst.interop.from_nnx(src)