netket.sampler.rules.HamiltonianRuleNumpy
netket.sampler.rules.HamiltonianRuleNumpy#
- class netket.sampler.rules.HamiltonianRuleNumpy#
Bases:
netket.sampler.rules.MetropolisRule
Rule for Numpy sampler backend proposing moves according to the terms in an operator.
In this case, the transition matrix is taken to be:
\[T( \mathbf{s} \rightarrow \mathbf{s}^\prime) = \frac{1}{\mathcal{N}(\mathbf{s})}\theta(|H_{\mathbf{s},\mathbf{s}^\prime}|),\]- Inheritance
- Attributes
- operator: netket.operator.AbstractOperator#
- 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 split.
It should return an immutable data structure.
- Parameters
sampler β The Metropolis sampler.
machine β A Flax module with the forward pass of the log-pdf.
params β The PyTree of parameters of the model.
key β A Jax PRNGKey.
- Returns
An optional state.
- random_state(sampler, machine, params, sampler_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.params (
Any
) β The PyTree of parameters of the model.sampler_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.
The default implementation returns the current rule_state without modifying it.
- 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 reset state of the rule. This returns the same type of
rule_state()
and might be None.
- transition(sampler, machine, parameters, state, rng, Ο)[source]#
Proposes a new configuration set of configurations $sigmaβ$ starting from the current chain configurations \(\sigma\).
The new configurations \(\sigma'\) should be a matrix with the same dimension as \(\sigma\).
This function should return a tuple. where the first element are the new configurations $sigmaβ$ and the second element is either None or an array of length Ο.shape[0] containing an optional log-correction factor. The correction factor should be non-zero when the transition rule is non-symmetrical.
- Parameters
sampler β The Metropolis sampler.
machine β A Flax module with the forward pass of the log-pdf.
params β The PyTree of parameters of the model.
sampler_state β The current state of the sampler. Should not modify it.
key β A Jax PRNGKey to use to generate new random configurations.
Ο β The current configurations stored in a 2D matrix.
- Returns
A tuple containing the new configurations \(\sigma'\) and the optional vector of log corrections to the transition probability.