Neural Networks

Base Functions

operator_learning.nn.fit_ridgels(cov_X, tikhonov_reg=0.0)

Fit the ridge least squares estimator for the transfer operator.

Parameters:
  • cov_X (torch.Tensor) – covariance matrix of the input data.

  • tikhonov_reg (float, optional) – Ridge regularization. Defaults to 0.0.

Returns:

FitResult – as defined in operator_learning.structs

Return type:

FitResult

operator_learning.nn.eig(fit_result, cov_XY)

Computes the eigendecomposition of the transfer operator.

Parameters:
  • fit_result (FitResult) – Fit result from the fit_ridgels function.

  • cov_XY (torch.Tensor) – Cross covariance matrix between the input and output data.

Returns:

EigResult – as defined in operator_learning.structs

Return type:

EigResult

operator_learning.nn.evaluate_eigenfunction(X, eig_result, which='right')
Parameters:
  • X (Tensor)

  • eig_result (EigResult)

  • which (Literal['left', 'right'])

Score & Loss Functions

operator_learning.nn.functional.spectral_contrastive_score(X, Y)
Parameters:
  • X (Tensor)

  • Y (Tensor)

operator_learning.nn.functional.dp_score(X, Y, relaxed=True, metric_deformation=1.0, center_covariances=True)

Deep Projection score by Kostic et al.[1].

Parameters:
  • X (torch.Tensor) – Covariates for the initial time steps.

  • Y (torch.Tensor) – Covariates for the evolved time steps.

  • relaxed (bool, optional) – Whether to use the relaxed (more numerically stable) or the full deep-projection loss. Defaults to True.

  • metric_deformation (float, optional) – Strength of the metric metric deformation loss: Defaults to 1.0.

  • center_covariances (bool, optional) – Use centered covariances to compute the Deep Projection score. Defaults to True.

Returns:

torch.Tensor – Deep Projection score

operator_learning.nn.functional.vamp_score(X, Y, schatten_norm=2, center_covariances=True)

Variational Approach for learning Markov Processes (VAMP) score by Wu and Noé[2].

Parameters:
  • X (torch.Tensor) – Covariates for the initial time steps.

  • Y (torch.Tensor) – Covariates for the evolved time steps.

  • schatten_norm (int, optional) – Computes the VAMP-p score with p = schatten_norm. Defaults to 2.

  • center_covariances (bool, optional) – Use centered covariances to compute the VAMP score. Defaults to True.

Raises:

NotImplementedError – If schatten_norm is not 1 or 2.

Returns:

torch.Tensor – VAMP score

operator_learning.nn.functional.logfro_loss(cov)

Logarithmic + Frobenious (metric deformation) loss as used in Kostic et al.[1], defined as \({{\rm Tr}}(C^{2} - C -\ln(C))\) .

Parameters:

cov (torch.tensor) – A symmetric positive-definite matrix.

Returns:

torch.tensor – Loss function

Linear Algebra Utilities

operator_learning.nn.linalg.covariance(X, Y=None, center=True, norm=None)

Covariance matrix

Parameters:
  • X (torch.Tensor) – Input covariates of shape (samples, features).

  • Y (torch.Tensor | None, optional) – Output covariates of shape (samples, features) Defaults to None.

  • center (bool, optional) – Whether to compute centered covariances. Defaults to True.

  • norm (float | None, optional) – Normalization factor. Defaults to None.

Returns:

torch.Tensor – Covariance matrix of shape (features, features). If Y is not None computes the cross-covariance between X and Y.

operator_learning.nn.linalg.sqrtmh(A)

Compute the square root of a Symmetric or Hermitian positive definite matrix or batch of matrices. Credits to https://github.com/pytorch/pytorch/issues/25481#issuecomment-1032789228.

Parameters:

A (Tensor)