netket.models.AbstractARNN#
- class netket.models.AbstractARNN[source]#
Bases:
Module
Base class for autoregressive neural networks.
Subclasses must implement the method
conditionals_log_psi()
, or override the methods__call__()
andconditionals()
if desired.They can override
conditional()
to implement the caching for fast autoregressive sampling. Seenetket.models.FastARNNConv1D
for an example.They must also implement the field
machine_pow
, which specifies the exponent to normalize the outputs of__call__()
.- Attributes
-
hilbert:
HomogeneousHilbert
# the Hilbert space. Only homogeneous unconstrained Hilbert spaces are supported.
-
hilbert:
- Methods
-
- conditional(inputs, index)[source]#
Computes the conditional probabilities for one site to take each value.
It should only be called successively with indices 0, 1, 2, …, as in the autoregressive sampling procedure.
- Parameters:
- Return type:
- Returns:
The probabilities with dimensions (batch, Hilbert.local_size).
- conditionals(inputs)[source]#
Computes the conditional probabilities for each site to take each value.
- Parameters:
inputs (
Union
[ndarray
,Array
]) – configurations with dimensions (batch, Hilbert.size).- Return type:
- Returns:
The probabilities with dimensions (batch, Hilbert.size, Hilbert.local_size).
Examples
>>> import pytest; pytest.skip("skip automated test of this docstring") >>> >>> p = model.apply(variables, σ, method=model.conditionals) >>> print(p[2, 3, :]) [0.3 0.7] # For the 3rd spin of the 2nd sample in the batch, # it takes probability 0.3 to be spin down (local state index 0), # and probability 0.7 to be spin up (local state index 1).
- abstract conditionals_log_psi(inputs)[source]#
Computes the log of the conditional wave-functions for each site to take each value.
- inverse_reorder(inputs, axis=0)[source]#
Transforms an array from ordered to unordered. See reorder.
- 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.