netket.experimental.models.RNN#

class netket.experimental.models.RNN[source]#

Bases: ARNNSequential

Base class for recurrent neural networks.

If either one of reorder_idx and inv_reorder_idx is unspecified, it can be deduced from another. If both are unspecified, they can be determined from graph.

If prev_neighbors is unspecified, it can be determined from graph and reorder_idx.

If all of reorder_idx, inv_reorder_idx, prev_neighbors, and graph are unspecified, there is a faster code path for 1D RNN.

Attributes
graph: Optional[AbstractGraph] = None#

graph of the physical system.

inv_reorder_idx: Optional[HashableArray] = None#

indices to transform the inputs from ordered to unordered. See netket.models.AbstractARNN.reorder() for details.

machine_pow: int = 2#

exponent to normalize the outputs of __call__.

prev_neighbors: Optional[HashableArray] = None#

previous neighbors of each site. An integer array of shape (hilbert.size, max_prev_neighbors). When the actual number of previous neighbors of a site is less than max_prev_neighbors, use -1 to denote zero paddings instead of memory from a neighbor.

reorder_idx: Optional[HashableArray] = None#

indices to transform the inputs from unordered to ordered. See netket.models.AbstractARNN.reorder() for details.

layers: int#

number of layers.

features: Union[Iterable[int], int]#

output feature density in each layer. If a single number is given, all layers except the last one will have the same number of features.

kernel_init: Callable[[Any, Sequence[int], Any], Union[ndarray, Array]]#

initializer for the weights.

bias_init: Callable[[Any, Sequence[int], Any], Union[ndarray, Array]]#

initializer for the biases.

hilbert: HomogeneousHilbert#

the Hilbert space. Only homogeneous unconstrained Hilbert spaces are supported.

Methods
__call__(inputs)#

Computes the log wave-functions for input configurations.

Parameters:

inputs (Union[ndarray, Array]) – configurations with dimensions (batch, Hilbert.size).

Return type:

Union[ndarray, Array]

Returns:

The log psi with dimension (batch,).

inverse_reorder(inputs, axis=0)[source]#

Transforms an array from ordered to unordered. See reorder.

Parameters:
  • inputs (Union[ndarray, Array]) – an array with ordered layout along a dimension.

  • axis (int) – the dimension to reorder on.

Return type:

Union[ndarray, Array]

Returns:

The array with unordered layout.

reorder(inputs, axis=0)[source]#

Transforms an array from unordered to ordered.

We call a 1D array ‘unordered’ if we need non-trivial indexing to access its elements in the autoregressive order, e.g., a[0], a[1], a[3], a[2] for the snake order. Otherwise, we call it ‘ordered’.

The inputs of conditionals_log_psi, conditionals, conditional, and __call__ are assumed to have unordered layout, and those inputs are always transformed through reorder before evaluating the network.

Subclasses may override reorder and inverse_reorder together to define this transformation.

Parameters:
  • inputs (Union[ndarray, Array]) – an array with unordered layout along a dimension.

  • axis (int) – the dimension to reorder on.

Return type:

Union[ndarray, Array]

Returns:

The array with ordered layout.