brainstate.interop.from_linen

Contents

brainstate.interop.from_linen#

brainstate.interop.from_linen(module, params, *, sample_input=None)[source]#

Convert a flax.linen module + params into an equivalent brainstate.nn model.

Parameters:
  • module (Any) – The linen module describing the architecture.

  • params (Any) – The variables produced by module.init(...) (e.g. {'params': ..., 'batch_stats': ...}).

  • sample_input (Any) – Required when the model contains convolution / spatial batch-norm layers.

Returns:

The converted model.

Return type:

Any