netket.sampler.rules.HamiltonianRule¶
-
class
netket.sampler.rules.
HamiltonianRule
(operator)[source]¶ Bases:
netket.sampler.metropolis.MetropolisRule
Rule 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}|),\]This rule only works on CPU! If you want to use it on GPU, you must use the numpy variant
netket.sampler.rules.HamiltonianRuleNumpy
together with the numpy metropolis samplernetket.sampler.MetropolisSamplerNumpy
.-
__init__
(operator)¶ Initialize self. See help(type(self)) for accurate signature.
- Parameters
operator (netket.operator._abstract_operator.AbstractOperator) –
- Return type
- 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 – The Metropolis sampler
machine – The forward evaluation function of the model, accepting PyTrees of parameters and inputs.
params – The dict of variables needed to evaluate the model.
key – A Jax PRNGKey rng state.
- 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()
.
-
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 (
Sampler
) – The Metropolis samplermachine (
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
- Returns
A new, resetted, state of the rule. This returns the same type of
sampler_state.rule_state()
and might be None.
-
-