netket.sampler.rules.LocalRuleΒΆ

class netket.sampler.rules.LocalRuleΒΆ

Bases: netket.sampler.MetropolisRule

A transition rule acting on the local degree of freedom.

This transition acts locally only on one local degree of freedom \(s_i\), and proposes a new state: \(s_1 \dots s^\prime_i \dots s_N\), where \(s^\prime_i \neq s_i\).

The transition probability associated to this sampler can be decomposed into two steps:

1. One of the site indices \(i = 1\dots N\) is chosen with uniform probability. 2. Among all the possible (\(m\)) values that \(s_i\) can take, one of them is chosen with uniform probability.

Inheritance
Inheritance diagram of netket.sampler.rules.LocalRule
Methods
init_state(sampler, machine, params, key)ΒΆ

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.

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.

  • key (Any) – A Jax PRNGKey.

Return type

Optional[Any]

Returns

An optional state.

random_state(sampler, machine, parameters, state, key)ΒΆ

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)ΒΆ

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

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]ΒΆ