Starting sampler with a specific state? #906
fabienalet
started this conversation in
General
Replies: 2 comments 2 replies
-
State is not a ket, but rather a structure holding the state of the sampler (which also includes the current batch of kets)
We could add what you say though, it is indeed a valid feature.
A non Hacky workaround is to define a new Rule (like local, or exchange) inheriting from whatever rule you want, and override the function `random_state` to give you a batch of states you want.
I’ll give you an example in a bit.
Il 3 set 2021, 17:36 +0200, Fabien Alet ***@***.***>, ha scritto:
… Hi all,
I have a basic question on how to start a sampler with a specific state, say the Neel state on four sites
neel = [1,0,1,0]
for a given machine ma and sampler sa
I tried
sampler.reset(machine=ma,state=neel)
but I'm missing the correct argument parameters (I tried several things but it failed).
Any simple workaround ? Thanks !
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi @PhilipVinc from netket.sampler.metropolis import MetropolisSampler
def NeelMetropolisHamiltonian(hilbert, hamiltonian, *args, **kwargs) -> MetropolisSampler:
rule = netket.sampler.rules.HamiltonianRule(hamiltonian)
def random_state(rule,
sampler,
machine,
parameters,
state,
key,
):
assert sampler.hilbert.size % 2 == 0
neel_state = jnp.array([0,1]*(sampler.hilbert.size//2))
return jnp.tile(neel_state, (sampler.n_chains_per_rank, 1))
return MetropolisSampler(hilbert, rule, *args, **kwargs) Thanks again! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I have a basic question on how to start a sampler with a specific state, say the Neel state on four sites
neel = [1,0,1,0]
for a given machine
ma
and samplersa
I tried
sampler.reset(machine=ma,state=neel)
but I'm missing the correct argument
parameters
(I tried several things but it failed).Any simple workaround ? Thanks !
Beta Was this translation helpful? Give feedback.
All reactions