netket.vqs#

This module defines the variational states, the heart of NetKet itself.

Inheritance diagram of netket.vqs

Abstract Interface#

VariationalState

Abstract class for variational states representing either pure states or mixed quantum states.

VariationalMixedState

Concrete Variational States#

FullSumState

Variational State for a variational quantum state computed on the whole Hilbert space without Monte Carlo sampling by summing over the whole Hilbert space.

MCState

Variational State for a Variational Neural Quantum State.

MCMixedState

Variational State for a Mixed Variational Neural Quantum State.

and the experimental Variational state for a single slater determinant state (which does not use Monte-Carlo sampling)

DeterminantVariationalState

Variational State for fermionic mean-field states (Hartree-Fock ansatz).

Functions#

apply_operator

Apply an operator to a variational state.

local_estimators

Compute per-sample local estimator data for operator op on vstate.

get_local_kernel

Returns the function computing the local estimator for the given variational state and operator.

get_local_kernel_arguments

Returns the samples of vstate used to compute the expectation value of the operator O, and the connected elements and matrix elements.

Freezing parameters#

The following functions return a new variational state in which a subset of the parameters has been frozen (moved from parameters into model_state), so they are automatically excluded from gradient computation and optimizer updates. See the freezing parameters example for a worked example.

freeze_parameters

Freeze a subset of model parameters in a variational state, removing them from gradient/QGT calculations.

unfreeze_parameters

Restore all frozen parameters in vstate to the trainable set.

Local-value kernels#

MCState computes the local estimators of jax operators with the kernels chosen by get_local_kernel(). The packed kernel below is an alternative, with the same arguments, that evaluates the network only on the connected configurations that differ from the sample. MCState uses it in place of the default kernels if the experimental flag NETKET_EXPERIMENTAL_PACKED_KERNEL is set (off by default), for instance with nk.config.netket_experimental_packed_kernel = True; it can also be called explicitly. It is experimental: it can change in a minor release, with a note in the changelog.

local_value_kernel_jax_packed

local_value kernel for MCState and jax-compatible operators that evaluates \(\log\psi\) only on the connected configurations \(x' \neq x\).