netket.vqs.VariationalMixedState#

class netket.vqs.VariationalMixedState#

Bases: VariationalState

Inheritance
Inheritance diagram of netket.vqs.VariationalMixedState
Attributes
hilbert#

The descriptor of the Hilbert space on which this variational state is defined.

hilbert_physical#
model_state#

The optional pytree with the mutable state of the model.

n_parameters#

The total number of parameters in the model.

parameters#

The pytree of the parameters of the model.

variables#

The PyTree containing the parameters and state of the model, used when evaluating it.

Methods
expect(O)#

Estimates the quantum expectation value for a given operator \(O\) or generic observable. In the case of a pure state \(\psi\) and an operator, this is \(\langle O\rangle= \langle \Psi|O|\Psi\rangle/\langle\Psi|\Psi\rangle\) otherwise for a mixed state \(\rho\), this is \(\langle O\rangle= \textrm{Tr}[\rho \hat{O}]/\textrm{Tr}[\rho]\).

Parameters:

O (AbstractOperator) – the operator or observable for which to compute the expectation value.

Return type:

Stats

Returns:

An estimation of the quantum expectation value \(\langle O\rangle\).

expect_and_forces(O, *, mutable=None)#

Estimates the quantum expectation value and the corresponding force vector for a given operator O.

The force vector \(F_j\) is defined as the covariance of log-derivative of the trial wave function and the local estimators of the operator. For complex holomorphic states, this is equivalent to the expectation gradient \(\frac{\partial\langle O\rangle}{\partial(\theta_j)^\star} = F_j\). For real-parameter states, the gradient is given by \(\frac{\partial\partial_j\langle O\rangle}{\partial\partial_j\theta_j} = 2 \textrm{Re}[F_j]\).

Parameters:
  • O (AbstractOperator) – The operator O for which expectation value and force are computed.

  • mutable (Union[bool, str, Collection[str], DenyList, None]) – Can be bool, str, or list. Specifies which collections in the model_state should be treated as mutable: bool: all/no collections are mutable. str: The name of a single mutable collection. list: A list of names of mutable collections. This is used to mutate the state of the model while you train it (for example to implement BatchNorm. Consult Flax’s Module.apply documentation for a more in-depth explanation).

Return type:

tuple[Stats, Any]

Returns:

An estimate of the quantum expectation value <O>. An estimate of the force vector \(F_j = \textrm{Cov}[\partial_j\log\psi, O_{\textrm{loc}}]\).

expect_and_grad(O, *, mutable=None, **kwargs)#

Estimates the quantum expectation value and its gradient for a given operator \(O\).

Parameters:
  • O (AbstractOperator) – The operator \(O\) for which expectation value and gradient are computed.

  • mutable (Union[bool, str, Collection[str], DenyList, None]) –

    Can be bool, str, or list. Specifies which collections in the model_state should be treated as mutable: bool: all/no collections are mutable. str: The name of a single mutable collection. list: A list of names of mutable collections. This is used to mutate the state of the model while you train it (for example to implement BatchNorm. Consult Flax’s Module.apply documentation for a more in-depth explanation).

  • use_covariance – whether to use the covariance formula, usually reserved for hermitian operators, \(\textrm{Cov}[\partial\log\psi, O_{\textrm{loc}}\rangle]\)

Return type:

tuple[Stats, Any]

Returns:

An estimate of the quantum expectation value <O>. An estimate of the gradient of the quantum expectation value <O>.

grad(Γ”, *, use_covariance=None, mutable=None)#

Estimates the gradient of the quantum expectation value of a given operator O.

Parameters:
Returns:

An estimation of the average gradient of the quantum expectation value <O>.

Return type:

array

init_parameters(init_fun=None, *, seed=None)#

Re-initializes all the parameters with the provided initialization function, defaulting to the normal distribution of standard deviation 0.01.

Warning

The init function will not change the dtype of the parameters, which is determined by the model. DO NOT SPECIFY IT INSIDE THE INIT FUNCTION

Parameters:
  • init_fun (Optional[Callable[[Any, Sequence[int], Any], Union[ndarray, Array]]]) – a jax initializer such as jax.nn.initializers.normal(). Must be a Callable taking 3 inputs, the jax PRNG key, the shape and the dtype, and outputting an array with the valid dtype and shape. If left unspecified, defaults to jax.nn.initializers.normal(stddev=0.01)

  • seed (Optional[Any]) – Optional seed to be used. The seed is synced across all MPI processes. If unspecified, uses a random seed.

quantum_geometric_tensor(qgt_type)#

Computes an estimate of the quantum geometric tensor G_ij.

This function returns a linear operator that can be used to apply G_ij to a given vector or can be converted to a full matrix.

Parameters:

qgt_type – the optional type of the quantum geometric tensor. By default it is automatically selected.

Returns:

A linear operator representing the quantum

geometric tensor.

Return type:

nk.optimizer.LinearOperator

reset()#

Resets the internal cache of th variational state. Called automatically when the parameters/state is updated.

to_array(normalize=True)#

Returns the dense-vector representation of this state.

Parameters:

normalize (bool) – If True, the vector is normalized to have L2-norm 1.

Return type:

Array

Returns:

An exponentially large vector representing the state in the computational basis.

to_matrix(normalize=True)[source]#

Returns the dense-matrix representation of this operator.

Parameters:

normalize (bool) – If True, the matrix is normalized to have trace 1.

Return type:

Array

Returns:

An exponentially large matrix representing the state in the computational basis.

to_qobj()[source]#

Convert this mixed state to a qutip density matrix Qobj.

Returns:

A qutip.Qobj object.