core.models.gemnet_oc.layers.radial_basis#

Copyright (c) Meta, Inc. and its affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.

Classes#

PolynomialEnvelope

Polynomial envelope function that ensures a smooth cutoff.

ExponentialEnvelope

Exponential envelope function that ensures a smooth cutoff,

GaussianBasis

Base class for all neural network modules.

SphericalBesselBasis

First-order spherical Bessel basis

BernsteinBasis

Bernstein polynomial basis,

RadialBasis

Module Contents#

class core.models.gemnet_oc.layers.radial_basis.PolynomialEnvelope(exponent: int)#

Bases: torch.nn.Module

Polynomial envelope function that ensures a smooth cutoff.

Parameters:

exponent (int) – Exponent of the envelope function.

p#
a: float#
b: float#
c: float#
forward(d_scaled: torch.Tensor) torch.Tensor#
class core.models.gemnet_oc.layers.radial_basis.ExponentialEnvelope#

Bases: torch.nn.Module

Exponential envelope function that ensures a smooth cutoff, as proposed in Unke, Chmiela, Gastegger, Schütt, Sauceda, Müller 2021. SpookyNet: Learning Force Fields with Electronic Degrees of Freedom and Nonlocal Effects

forward(d_scaled: torch.Tensor) torch.Tensor#
class core.models.gemnet_oc.layers.radial_basis.GaussianBasis(start: float = 0.0, stop: float = 5.0, num_gaussians: int = 50, trainable: bool = False)#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables:

training (bool) – Boolean represents whether this module is in training or evaluation mode.

coeff#
forward(dist: torch.Tensor) torch.Tensor#
class core.models.gemnet_oc.layers.radial_basis.SphericalBesselBasis(num_radial: int, cutoff: float)#

Bases: torch.nn.Module

First-order spherical Bessel basis

Parameters:
  • num_radial (int) – Number of basis functions. Controls the maximum frequency.

  • cutoff (float) – Cutoff distance in Angstrom.

norm_const#
frequencies#
forward(d_scaled: torch.Tensor) torch.Tensor#
class core.models.gemnet_oc.layers.radial_basis.BernsteinBasis(num_radial: int, pregamma_initial: float = 0.45264)#

Bases: torch.nn.Module

Bernstein polynomial basis, as proposed in Unke, Chmiela, Gastegger, Schütt, Sauceda, Müller 2021. SpookyNet: Learning Force Fields with Electronic Degrees of Freedom and Nonlocal Effects

Parameters:
  • num_radial (int) – Number of basis functions. Controls the maximum frequency.

  • pregamma_initial (float) – Initial value of exponential coefficient gamma. Default: gamma = 0.5 * a_0**-1 = 0.94486, inverse softplus -> pregamma = log e**gamma - 1 = 0.45264

pregamma#
softplus#
forward(d_scaled: torch.Tensor) torch.Tensor#
class core.models.gemnet_oc.layers.radial_basis.RadialBasis(num_radial: int, cutoff: float, rbf: dict[str, str] | None = None, envelope: dict[str, str | int] | None = None, scale_basis: bool = False)#

Bases: torch.nn.Module

Parameters:
  • num_radial (int) – Number of basis functions. Controls the maximum frequency.

  • cutoff (float) – Cutoff distance in Angstrom.

  • rbf (dict = {"name": "gaussian"}) – Basis function and its hyperparameters.

  • envelope (dict = {"name": "polynomial", "exponent": 5}) – Envelope function and its hyperparameters.

  • scale_basis (bool) – Whether to scale the basis values for better numerical stability.

inv_cutoff#
scale_basis#
forward(d: torch.Tensor) torch.Tensor#