netket.errors.NNXModuleToSamplerInput

netket.errors.NNXModuleToSamplerInput#

exception netket.errors.NNXModuleToSamplerInput[source]#

Error thrown when attempting to use a sampler with a bare NNX module.

NetKet’s samplers do not accept a nnx module directly, because the nnx module wraps both the ‘logic’ and the ‘variables’. Instead, the NNX module must be converted to a linen-compatible interface.

The simplest way to do that is to call {func}`netket.utils.model_frameworks.maybe_wrap_module` which will return a linen-like static class and the variable dictionary, which you can then pass to the sampler.

You can also implement this logic yourself if you want to customize it more, by using {func}`flax.nnx.split` and {func}`flax.nnx.merge`, knowing that the {class}`flax.nnx.GraphDef` state can be treated as static.