mlcolvar.core.loss.TDALoss

class mlcolvar.core.loss.TDALoss(n_states: int, target_centers: list | Tensor, target_sigmas: list | Tensor, alpha: float = 1, beta: float = 100)[source]

Bases: Module

Compute a loss function as the distance from a simple Gaussian target distribution.

__init__(n_states: int, target_centers: list | Tensor, target_sigmas: list | Tensor, alpha: float = 1, beta: float = 100)[source]

Constructor.

Parameters:
  • n_states (int) – Number of states. The integer labels are expected to be in between 0 and n_states-1.

  • target_centers (list or torch.Tensor) – Shape (n_states, n_cvs). Centers of the Gaussian targets.

  • target_sigmas (list or torch.Tensor) – Shape (n_states, n_cvs). Standard deviations of the Gaussian targets.

  • alpha (float, optional) – Centers_loss component prefactor, by default 1.

  • beta (float, optional) – Sigmas loss compontent prefactor, by default 100.

Methods

__init__(n_states, target_centers, target_sigmas)

Constructor.

forward(H, labels[, return_loss_terms])

Compute the value of the loss function.

forward(H: Tensor, labels: Tensor, return_loss_terms: bool = False) Tensor[source]

Compute the value of the loss function.

Parameters:
  • H (torch.Tensor) – Shape (n_batches, n_features). Output of the NN.

  • labels (torch.Tensor) – Shape (n_batches,). Labels of the dataset.

  • return_loss_terms (bool, optional) – If True, the loss terms associated to the center and standard deviations of the target Gaussians are returned as well. Default is False.

Returns:

  • loss (torch.Tensor) – Loss value.

  • loss_centers (torch.Tensor, optional) – Only returned if return_loss_terms is True. The value of the loss term associated to the centers of the target Gaussians.

  • loss_sigmas (torch.Tensor, optional) – Only returned if return_loss_terms is True. The value of the loss term associated to the standard deviations of the target Gaussians.

Attributes

T_destination

call_super_init

dump_patches

training