mlcolvar.core.loss.GeneratorLoss¶
- class mlcolvar.core.loss.GeneratorLoss(r: int, eta: float, friction: Tensor, alpha: float, descriptors_derivatives: SmartDerivatives | Tensor = None, n_dim: int = 3, u_stat: bool = True)[source]¶
Bases:
ModuleComputes the loss function to learn a representation for the resolvent of the infinitesimal generator
- __init__(r: int, eta: float, friction: Tensor, alpha: float, descriptors_derivatives: SmartDerivatives | Tensor = None, n_dim: int = 3, u_stat: bool = True)[source]¶
Computes the loss to learn a representation on which the resolvent of the infinitesimal generator can be learned
- Parameters:
r (int) – Number of eigenfunctions wanted, i.e., number of outputs of model.
eta (float) – Hyperparameter for the shift to define the resolvent, i.e., $(eta I-_mathcal{L})^{-1}$
friction (torch.Tensor) – Langevin friction, i.e., $sqrt{k_B*T/(gamma*m_i)}$
alpha (float) – Hyperparamer that scales the contribution of orthonormality loss to the total loss, i.e., L = L_ef + alpha*L_ortho
descriptors_derivatives (Union[SmartDerivatives, torch.Tensor], optional) – Derivatives of descriptors wrt atomic positions (if used) to speed up calculation of gradients, by default None. Can be either:
A SmartDerivatives object to save both memory and time, see also mlcolvar.core.loss.committor_loss.SmartDerivatives
A torch.Tensor with the derivatives to save time, memory-wise could be less efficient
ref_idx (torch.Tensor, optional) – Reference indeces for the unshuffled dataset for properly handling batching/splitting/shuffling when descriptors derivatives are provided, by default None. Ref_idx can be generated automatically using SmartDerivatives or by setting create_ref_idx=True when initializing a DictDataset. See also mlcolvar.core.loss.utils.smart_derivatives.SmartDerivatives
n_dim (int) – Number of dimensions, by default 3.
u_stat (bool) – Do we use U-statistics to compute the loss
Methods
__init__(r, eta, friction, alpha[, ...])Computes the loss to learn a representation on which the resolvent of the infinitesimal generator can be learned
forward(input, output, weights[, ref_idx])Define the computation performed at every call.
- forward(input: Tensor, output: Tensor, weights: Tensor, ref_idx: Tensor = None) Tuple[Tensor, Tensor, Tensor][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
Attributes
T_destination
call_super_init
dump_patches
training