netket.sampler.MetropolisRuleΒΆ
-
class
netket.sampler.
MetropolisRule
(*args, __precompute_cached_properties=False, __skip_preprocess=False, **kwargs)ΒΆ Bases:
object
Base class for transition rules of Metropolis, such as Local, Exchange, Hamiltonian and several others.
- Inheritance
- Methods
-
init_state
(sampler, machine, params, key)[source]ΒΆ Initialises the optional internal state of the Metropolis sampler transition rule.
The provided key is unique and does not need to be splitted.
It should return an immutable data structure.
-
random_state
(sampler, machine, parameters, state, key)[source]ΒΆ Generates a random state compatible with this rule.
By default this calls
netket.hilbert.random.random_state()
.- Parameters
sampler (
MetropolisSampler
) β The Metropolis sampler.machine (
Module
) β A Flax module with the forward pass of the log-pdf.parameters (
Any
) β The PyTree of parameters of the model.state (
SamplerState
) β The current state of the sampler. Should not modify it.key (
Any
) β The PRNGKey to use to generate the random state.
-
replace
(**updates)ΒΆ Returns a new object replacing the specified fields with new values.
-
reset
(sampler, machine, params, sampler_state)[source]ΒΆ Resets the internal state of the Metropolis Sampler Transition Rule.
- Parameters
sampler (
MetropolisSampler
) β The Metropolis sampler.machine (
Module
) β A Flax module with the forward pass of the log-pdf.params (
Any
) β The PyTree of parameters of the model.sampler_state (
SamplerState
) β The current state of the sampler. Should not modify it.
- Return type
- Returns
A new, resetted, state of the rule. This returns the same type of
sampler_state.rule_state()
and might be None.
-
transition
(sampler, machine, parameters, state, key, Ο)[source]ΒΆ - Return type
- Parameters
sampler (netket.sampler.MetropolisSampler) β
machine (flax.linen.module.Module) β
parameters (Any) β
state (netket.sampler.SamplerState) β
key (Any) β
Ο (jax._src.numpy.lax_numpy.ndarray) β
-