netket.machine.FFNN¶
-
class
netket.machine.
FFNN
¶ A feedforward neural network (FFNN) Machine. This machine is constructed by providing a sequence of layers from the
layer
class. Each layer implements a transformation such that the information is transformed sequentially as it moves from the input nodes through the hidden layers and to the output nodes.-
__init__
(self: netket._C_netket.machine.FFNN, hilbert: netket._C_netket.hilbert.Hilbert, layers: tuple) → None¶ Constructs a new
FFNN
machine:- Parameters
hilbert – Hilbert space object for the system.
layers – Tuple of layers.
Examples
A
FFNN
machine with 2 layers. for a one-dimensional L=20 spin-half system:>>> from netket.layer import SumOutput >>> from netket.layer import FullyConnected >>> from netket.layer import Lncosh >>> from netket.hilbert import Spin >>> from netket.graph import Hypercube >>> from netket.machine import FFNN >>> g = Hypercube(length=20, n_dim=1) >>> hi = Spin(s=0.5, total_sz=0, graph=g) >>> layers = (FullyConnected(input_size=20,output_size=20,use_bias=True),Lncosh(input_size=20),SumOutput(input_size=20)) >>> ma = FFNN(hi, layers) >>> print(ma.n_par) 420
Methods
__init__
(self, hilbert, layers)Constructs a new
FFNN
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
The hilbert space object of the system.
Whether the given wave-function is a holomorphic function of its parameters
The number of parameters in the machine.
The number of inputs into the machine aka visible units in the case of Restricted Boltzmann Machines.
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¶ Loads machine’s state from state.
-
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.
-