mlcolvar.core.loss.AutocorrelationLoss

class mlcolvar.core.loss.AutocorrelationLoss(reduce_mode: str = 'sum2', invert_sign: bool = True)[source]

Bases: Module

(Weighted) autocorrelation loss.

Computes the sum (or another reducing functions) of the eigenvalues of the autocorrelation matrix. This is the same loss function used in DeepTICA.

__init__(reduce_mode: str = 'sum2', invert_sign: bool = True)[source]

Constructor.

Parameters:
  • reduce_mode (str) – This determines how the eigenvalues are reduced, e.g., sum, sum2 (see also ReduceEigenvaluesLoss). The default is 'sum2'.

  • invert_sign (bool, optional) – Whether to return the negative autocorrelation in order to be minimized with gradient descent methods. Default is True.

Methods

__init__([reduce_mode, invert_sign])

Constructor.

forward(x, x_lag[, weights, weights_lag])

Estimate the autocorrelation.

forward(x: Tensor, x_lag: Tensor, weights: Tensor | None = None, weights_lag: Tensor | None = None) Tensor[source]

Estimate the autocorrelation.

Parameters:
  • x (torch.Tensor) – Shape (n_batches, n_features). The features of the sample at time t.

  • x_lag (torch.Tensor) – Shape (n_batches, n_features). The features of the sample at time t + lag.

  • weights (torch.Tensor, optional) – Shape (n_batches,) or (n_batches, 1). The weights associated to x at time t. Default is None.

  • weights_lag (torch.Tensor, optional) – Shape (n_batches,) or (n_batches, 1). The weights associated to x at time t + lag. Default is None.

Returns:

loss – Loss value.

Return type:

torch.Tensor

Attributes

T_destination

call_super_init

dump_patches

training