module adabmDCA.statmech
function compute_energy
compute_energy(x: Tensor, params: Dict[str, Tensor]) → Tensor
Compute the DCA energy for a batch of sequences.
Args:
x(torch.Tensor): Tensor of shape (batch_size, L, q) - batch of one-hot encoded sequences.params(Dict[str, torch.Tensor]): Parameters of the model. - "bias": Tensor of shape (L, q) - local biases. - "coupling_matrix": Tensor of shape (L, q, L, q) - coupling matrix.
Returns:
torch.Tensor: Tensor of shape (batch_size,) - DCA energy for each sequence in the batch.
function compute_log_likelihood
compute_log_likelihood(
fi: Tensor,
fij: Tensor,
params: Dict[str, Tensor],
logZ: float
) → float
Compute the log-likelihood of the model.
Args:
fi(torch.Tensor): Single-site frequencies of the data.fij(torch.Tensor): Two-site frequencies of the data.params(Dict[str, torch.Tensor]): Parameters of the model.logZ(float): Log-partition function of the model.
Returns:
float: Log-likelihood of the model.
function enumerate_states
enumerate_states(L: int, q: int, device: device = device(type='cpu')) → Tensor
Enumerate all possible states of a system of L sites and q states.
Args:
L(int): Number of sites.q(int): Number of states.device(torch.device, optional): Device to store the states. Defaults to "cpu".
Returns:
torch.Tensor: All possible states.
function compute_logZ_exact
compute_logZ_exact(all_states: Tensor, params: Dict[str, Tensor]) → float
Compute the log-partition function of the model.
Args:
all_states(torch.Tensor): All possible states of the system.params(Dict[str, torch.Tensor]): Parameters of the model.
Returns:
float: Log-partition function of the model.
function compute_entropy
compute_entropy(chains: Tensor, params: Dict[str, Tensor], logZ: float) → float
Compute the entropy of the DCA model.
Args:
chains(torch.Tensor): Chains that are supposed to be an equilibrium realization of the model.params(Dict[str, torch.Tensor]): Parameters of the model.logZ(float): Log-partition function of the model.
Returns:
float: Entropy of the model.
function iterate_tap
iterate_tap(
mag: Tensor,
params: Dict[str, Tensor],
max_iter: int = 500,
epsilon: float = 0.0001
) → Tensor
Iterates the TAP equations until convergence.
Args:
mag(torch.Tensor): Initial magnetizations.params(Dict[str, torch.Tensor]): Parameters of the model.max_iter(int, optional): Maximum number of iterations. Defaults to 500.epsilon(float, optional): Convergence threshold. Defaults to 1e-4.
Returns:
torch.Tensor: Fixed point magnetizations of the TAP equations.
This file was automatically generated via lazydocs.