Skip to content

Instantly share code, notes, and snippets.

@PhilipVinc

PhilipVinc/ex.py Secret

Created January 18, 2021 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PhilipVinc/f213e1d4e85a0f20cff5d73092a647b8 to your computer and use it in GitHub Desktop.
Save PhilipVinc/f213e1d4e85a0f20cff5d73092a647b8 to your computer and use it in GitHub Desktop.
import netket as nk
import numpy as np
import jax
import flax
from flax import linen as nn
from jax import numpy as jnp
from netket import nn as nknn
g = nk.graph.Chain(8)
hi = nk.hilbert.Spin(1 / 2) ** g.n_nodes
H = nk.operator.Ising(hi, graph=g, h=1.0)
ma = nk.nn.models.RBM()
sa = nk.sampler.MetropolisLocal(hi) # , dtype=np.float64
vs = nk.variational_states.ClassicalVariationalState(ma, sa, n_samples=1000)
optim = flax.optim.GradientDescent(learning_rate=0.1)
gs = nk.Vmc(H, optim, variational_state=vs)
gs.run(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment