netket.sampler.MetropolisRule¶

class netket.sampler.MetropolisRule[source]¶

Bases: object

Base class for Transition rules of Metropolis, such as Local, Exchange, Hamiltonian and several others.

__init__()¶

Initialize self. See help(type(self)) for accurate signature.

Return type

None

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 datastructure.

Parameters
  • sampler (Sampler) – The Metropolis sampler

  • machine (Callable) – The forward evaluation function of the model, accepting PyTrees of parameters and inputs.

  • params (Any) – The dict of variables needed to evaluate the model.

  • key (Any) – A Jax PRNGKey rng state.

Return type

Optional[Any]

Returns

An Optional State.

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 (Sampler) – the sampler

  • machine (Callable) – the function to evaluate the model

  • parameters (Any) – the parameters of the model

  • state (SamplerState) – the current sampler state

  • 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 (Sampler) – The Metropolis sampler

  • machine (Callable) – The forward evaluation function of the model, accepting PyTrees of parameters and inputs.

  • params (Any) – The dict of variables needed to evaluate the model.

  • sampler_state (SamplerState) – The current state of the sampler. Should not modify it.

Return type

Optional[Any]

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

ndarray

Parameters
  • sampler (netket.sampler.base.Sampler) –

  • machine (Callable) –

  • parameters (Any) –

  • state (netket.sampler.base.SamplerState) –

  • key (Any) –

  • σ (jax._src.numpy.lax_numpy.ndarray) –