# netket.machine.RbmSpinPhase¶

class netket.machine.RbmSpinPhase

A fully connected Restricted Boltzmann Machine (RBM) with real-valued parameters. In this case, two RBMs are taken to parameterize, respectively, phase and amplitude of the wave-function. This type of RBM has spin 1/2 hidden units and is defined by:

$\Psi(s_1,\dots s_N) = e^{\sum_i^N a_i s_i} \times \Pi_{j=1}^M \cosh \left(\sum_i^N W_{ij} s_i + b_j \right)$

for arbitrary local quantum numbers $$s_i$$.

__init__(self: netket._C_netket.machine.RbmSpinPhase, hilbert: netket._C_netket.hilbert.Hilbert, n_hidden: int = 0, alpha: int = 0, use_visible_bias: bool = True, use_hidden_bias: bool = True) → None

Constructs a new RbmSpinPhase machine:

Parameters
• hilbert – Hilbert space object for the system.

• n_hidden – Number of hidden units.

• alpha – Hidden unit density.

• use_visible_bias – If True then there would be a bias on the visible units. Default True.

• use_hidden_bias – If True then there would be a bias on the visible units. Default True.

Examples

A RbmSpinPhase machine with hidden unit density alpha = 2 for a one-dimensional L=20 spin-half system:

>>> from netket.machine import RbmSpinPhase
>>> from netket.hilbert import Spin
>>> from netket.graph import Hypercube
>>> g = Hypercube(length=20, n_dim=1)
>>> hi = Spin(s=0.5, total_sz=0, graph=g)
>>> ma = RbmSpinPhase(hilbert=hi,alpha=2)
>>> print(ma.n_par)
1720


Methods

 __init__(self, hilbert, n_hidden, alpha, …) Constructs a new RbmSpinPhase machine: der_log(self, v) Member function to obtain the derivatives of log value of machine given an input wrt the machine’s parameters. init_random_parameters(self, sigma, seed, …) Member function to initialise machine parameters. load(self, filename) Member function to load machine parameters from a json file. load_state_dict(self, arg0) Loads machine’s state from state. log_norm(self) Returns the log of the L2 norm of the wave-function. log_val(self, v) Member function to obtain log value of machine given an input vector. log_val_diff(self, v, 1]], tochange, newconf) Member function to obtain difference in log value of machine given an input and a change to the input. save(self, filename) Member function to save the machine parameters. state_dict(self) Returns machine’s state as a dictionary. to_array(self, normalize) Returns a numpy array representation of the machine.

Attributes

 hilbert The hilbert space object of the system. is_holomorphic Whether the given wave-function is a holomorphic function of its parameters n_par The number of parameters in the machine. n_visible The number of inputs into the machine aka visible units in the case of Restricted Boltzmann Machines. parameters List containing the parameters within the layer.
der_log(self: netket._C_netket.machine.Machine, v: numpy.ndarray[float64]) → object

Member function to obtain the derivatives of log value of machine given an input wrt the machine’s parameters.

Parameters

v – Input vector to machine.

property hilbert

The hilbert space object of the system.

Type

netket.hilbert.Hilbert

init_random_parameters(self: netket._C_netket.machine.Machine, sigma: float = 0.1, seed: Optional[int] = None, rand_gen: std::__1::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u> = None) → None

Member function to initialise machine parameters.

Parameters
• sigma – Standard deviation of normal distribution from which parameters are drawn.

• seed – The random number generator seed. If not given, rand_gen is considered instead.

• rand_gen – The random number generator (netket.RandomEngine) to be used. If not given, the global random generator (with its current state) is used.

property is_holomorphic

Whether the given wave-function is a holomorphic function of its parameters

Type

bool

load(self: netket._C_netket.machine.Machine, filename: str) → None

Member function to load machine parameters from a json file.

Parameters

filename – name of file to load parameters from.

load_state_dict(self: netket._C_netket.machine.Machine, arg0: dict) → None

log_norm(self: netket._C_netket.machine.Machine) → float

Returns the log of the L2 norm of the wave-function. This operation is a brute-force calculation, and should thus only be performed for low-dimensional Hilbert spaces.

This method requires an indexable Hilbert space.

log_val(self: netket._C_netket.machine.Machine, v: numpy.ndarray[float64]) → object

Member function to obtain log value of machine given an input vector.

Parameters

v – Input vector to machine.

log_val_diff(self: netket._C_netket.machine.Machine, v: numpy.ndarray[float64[m, 1]], tochange: List[List[int]], newconf: List[List[float]]) → numpy.ndarray[complex128[m, 1]]

Member function to obtain difference in log value of machine given an input and a change to the input.

Parameters
• v – Input vector to machine.

• tochange – list containing the indices of the input to be changed

• newconf – list containing the new (changed) values at the indices specified in tochange

property n_par

The number of parameters in the machine.

Type

int

property n_visible

The number of inputs into the machine aka visible units in the case of Restricted Boltzmann Machines.

Type

int

property parameters

List containing the parameters within the layer. Read and write

Type

list

save(self: netket._C_netket.machine.Machine, filename: str) → None

Member function to save the machine parameters.

Parameters

filename – name of file to save parameters to.

state_dict(self: netket._C_netket.machine.Machine) → object

Returns machine’s state as a dictionary. Similar to torch.nn.Module.state_dict.

to_array(self: netket._C_netket.machine.Machine, normalize: bool = True) → numpy.ndarray[complex128[m, 1]]

Returns a numpy array representation of the machine. The returned array is normalized to 1 in L2 norm. Note that, in general, the size of the array is exponential in the number of quantum numbers, and this operation should thus only be performed for low-dimensional Hilbert spaces.

This method requires an indexable Hilbert space.