xnn.common.featurizers.radial.ExpNormalSmearing#

class xnn.common.featurizers.radial.ExpNormalSmearing(n_rbf=32, cutoff=5.0, cutoff_lower=0.0, trainable=True)[source]#

Bases: Module

Exponential-normal radial basis (TorchMD-Net ET / TensorNet, BAMBOO).

Expands a distance r onto n_rbf Gaussians placed in exponential distance space, dense at short range and sparse near the cutoff, times a cosine cutoff envelope:

phi_k(r) = cos_cutoff(r) *
           exp(-beta_k * (exp(alpha * (cutoff_lower - r)) - mu_k) ** 2)

with alpha = 5 / (cutoff - cutoff_lower). The centers mu_k run linearly from exp(cutoff_lower - cutoff) to 1 and every width starts at (2 / n_rbf * (1 - exp(cutoff_lower - cutoff))) ** -2 (Thoelke & De Fabritiis 2022, eq 1, the PhysNet convention).

Parameters:
  • n_rbf (int, optional) – Number of basis functions, by default 32.

  • cutoff (float, optional) – Upper cutoff in the units of the distances, by default 5.0.

  • cutoff_lower (float, optional) – Lower cutoff, by default 0.0.

  • trainable (bool, optional) – Learn the centers and widths (True, the default) or keep them as buffers.

Variables:
  • means (Tensor) – The centers mu_k, shape (n_rbf,).

  • betas (Tensor) – The inverse widths beta_k, shape (n_rbf,).

  • alpha (float) – The exponential-space scale 5 / (cutoff - cutoff_lower).

reset_parameters()[source]#

Reset the centers and widths to their default values in place.

Return type:

None

exact_constants()[source]#

Rebuild fixed float64 centers and widths exactly.

A float32 build or checkpoint leaves them float32-rounded; trainable ones are learned values and stay, as do stored ones that are not the defaults up to rounding. See exact_float64_constants().

Returns:

Whether any value changed.

Return type:

bool

forward(r)[source]#

Expand distances onto the basis.

Parameters:

r (Tensor) – Interatomic distances of arbitrary shape (...).

Returns:

The expansion of shape (..., n_rbf), zero at and beyond the cutoff.

Return type:

Tensor